damienbod / AspNetCoreHybridFlowWithApi

Different ASP.NET Core applications using OpenID Connect Hybrid flow Code Flow, Code Flow with PKCE, JWT APIs, MFA examples
https://damienbod.com/2018/02/02/securing-an-asp-net-core-mvc-application-which-uses-a-secure-api/
MIT License
356 stars 70 forks source link

Unable to validate the 'id_token', no suitable ISecurityTokenValidator was found for: ''." #11

Open adsengineer opened 4 years ago

adsengineer commented 4 years ago

I am getting this error when using WebCodeFlowPkceClient. I have configured all the parameters and succeed in getting authorization code and token, but after that above error is showing. Can you, please, help me? Am I doing something wrong? Those are my parameters: options.ClientId = config["Connection:ClientId"]; options.ClientSecret = config["Connection:ClientSecret"]; options.Scope.Clear(); options.Authority = config["Connection:Uri"]; options.CallbackPath = new PathString("/signin"); options.SignInScheme = "Cookies"; options.RequireHttpsMetadata = true; options.ResponseType = "code"; options.ResponseMode = "query"; options.UsePkce = true; options.SaveTokens = true; options.GetClaimsFromUserInfoEndpoint = true;

damienbod commented 3 years ago

Do you still have this problem, validating this and cannot reproduce. Is this a different repo?

Greetings Damien

pekaaw commented 11 months ago

I experienced pretty much the same thing, authenticating with Azure AD B2C. To figure out the problem I added temporary code to log the IdToken and AccessToken. In my case the IdToken was empty, and I figured out that I had not granted admin consent to the openid permission. For @adsengineer it looks like the IdToken is only a dot '.', so not a valid IdToken.

When I granted admin consent I managed to log in successfully with Authorization Code Flow, using .NET Framework 4.7.2 with the Microsoft.Owin.Security.OpenIdConnect package.