Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Register IIdentityServerInteractionService in Identity Server 4 for OpenID Connect

I'm trying to follow this tutorial on Adding User Authentication with OpenID Connect from the Identity Server 4 docs but I get the following error when I start up the mvc client:

InvalidOperationException: Unable to resolve service for type 'IdentityServer4.Services.IIdentityServerInteractionService' while attempting to activate 'IdentityServer4.Quickstart.UI.HomeController'.

How do I go about registering the Identity Server Interaction Service? Its sounds like an issue with DI.

like image 284
iKnowNothing Avatar asked Jan 11 '17 17:01

iKnowNothing


1 Answers

You get this error when there is no implementation available of the interface IIdentityServerInteractionService in the dependency injection container. The HomeController of the Quickstart example requests for an implementation of IIdentityServerInteractionService in the constructor:

public HomeController(IIdentityServerInteractionService interaction)
{
    _interaction = interaction;
}

You should add services.AddIdentityServer(); in the ConfigureServices method in your startup class. IdentityServer will inject an implementation of IIdentityServerInteractionService, namingly the DefaultIdentityServerInteractionService.

like image 151
user1336 Avatar answered Sep 26 '22 00:09

user1336