我正尝试在 Adding User Authentication with OpenID Connect 上学习本教程来自 Identity Server 4 文档,但在启动 mvc 客户端时出现以下错误:
InvalidOperationException: Unable to resolve service for type 'IdentityServer4.Services.IIdentityServerInteractionService' while attempting to activate 'IdentityServer4.Quickstart.UI.HomeController'.
如何注册 Identity Server Interaction Service?这听起来像是 DI 的问题。
最佳答案
当依赖项注入(inject)容器中的接口(interface) IIdentityServerInteractionService
没有可用的实现时,您会收到此错误。
快速入门示例的 HomeController 请求在构造函数中实现 IIdentityServerInteractionService
:
public HomeController(IIdentityServerInteractionService interaction)
{
_interaction = interaction;
}
您应该在启动类的ConfigureServices
方法中添加services.AddIdentityServer();
。 IdentityServer 将注入(inject) IIdentityServerInteractionService
的实现,命名为 DefaultIdentityServerInteractionService
。
关于c# - 在 Identity Server 4 中为 OpenID Connect 注册 IIdentityServerInteractionService,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41597465/