Search code examples
c#nugetasp.net-core-2.0identityserver4dotnet-cli

Can't add IdentityServer4 NuGet package to ASP.NET Core project properly and VS Code is not showing intellisense


I've added IdentityServer4 NuGet package to ASP.NET core project using dotnet cli. Then written the following code on Startup class.

public void ConfigureServices(IServiceCollection services)
    {           
        services.AddIdentityServer()
            .AddInMemoryClients(new Client[] 
                { 
                    new Client
                    { 
                        ClientId = "react client", 
                        ClientName = "React Client",
                        AllowedGrantTypes = GrantTypes.Implicit,
                        RedirectUrls = {"http://localhost:51009/"},
                        AllowedScopes = { "openid"}
                    }
                });            
        services.AddMvc();
    }

Then when I build the project it shows error: The type or namespace name 'Client' could not be found (are you missing a using directive or an assembly reference?)

Moreover VS Code doesn't show any suggestion for IdentityServer related code.

And when I search IdentityServer4 on NuGet website it shows result like following: Search result on NuGet website




And when I search IdentityServer4 on Visual Studio 2017 it shows result like following: Search result on Visual Studio 2017


Solution

  • The IdentityServer4 Client class is located in the IdentityServer4.Models namespace which is included in the nuget-package.

    Adding the using-statement where the model/models are needed should resolve the issue

    using IdentityServer4.Models