1

When I call AddOpenIdConnect(), I get an exception:

An unhandled exception occurred while processing the request. TypeLoadException: Could not load type 'Microsoft.AspNetCore.Authentication.RequestPathBaseCookieBuilder' from assembly 'Microsoft.AspNetCore.Authentication, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions..ctor()

Example Code:

        public void ConfigureServices(IServiceCollection services)
        {           
            services.AddMvc();

            var builder = services.AddIdentityServer(options =>
            {
                options.Events.RaiseErrorEvents = true;
                options.Events.RaiseInformationEvents = true;
                options.Events.RaiseFailureEvents = true;
                options.Events.RaiseSuccessEvents = true;
            })
            .AddInMemoryIdentityResources(Config.GetIdentityResources())
            .AddInMemoryApiResources(Config.GetApis())
            .AddInMemoryClients(Config.GetClients());

            services.AddAuthentication()
                .AddOpenIdConnect("aad", "Azure AD", options =>
                {
                    options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
                    options.SignOutScheme = IdentityServerConstants.SignoutScheme;

                    options.Authority = "https://login.windows.net/...";
                    options.ClientId = "client_id";
                    options.ResponseType = "id_token";
                    options.CallbackPath = new PathString("/signin-aad");
                    options.SignedOutCallbackPath = new PathString("/signout-callback-aad");
                    options.RemoteSignOutPath = new PathString("/signout-aad");
                    options.TokenValidationParameters = new TokenValidationParameters
                    {
                        NameClaimType = "name",
                        RoleClaimType = "role"
                    };
                });
        }
2
  • Are you trying to protect an API that is co-located inside your Identity service? If so then have a look at this docs.identityserver.io/en/latest/topics/add_apis.html. Commented Sep 20, 2019 at 6:39
  • No, I am not. There is no API co-located here. I am just trying to get a functional IS 3.0.0 running in a POC project. Commented Sep 20, 2019 at 15:05

2 Answers 2

2

You need to add an updated nuget reference to Microsoft.AspNetCore.Authentication.OpenIdConnect (now it's at 3.3.1).

This DLL only targets netcore, so you will have to change the TargetFramework from netstandard to netcoreapp.

Which sucks, but I do not believe there is any other option.

Sign up to request clarification or add additional context in comments.

Comments

0

You forgot to add the cookie Adding User Authentication with OpenID Connect

services.AddAuthentication(options =>
    {
        options.DefaultScheme = "Cookies";
        options.DefaultChallengeScheme = "oidc";
    })
    .AddCookie("Cookies")
    .AddOpenIdConnect("oidc", options =>
    {
        options.Authority = "http://localhost:5000";
        options.RequireHttpsMetadata = false;

        options.ClientId = "mvc";
        options.SaveTokens = true;
    });

3 Comments

It still throws that error. It seems there is an issue with dependencies on 3.0.0
Steps to repro: 1. dotnet new is4aspid -n ErrorIn30 2. Update to core 3.0 in project 3. Update packages 4. Add OpenIdConnect in startup configure services 5. Debug
I followed your repro steps with SDK 3.0.100-rc1-014190 and did not reproduce the error when deugging.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.