aspnet-contrib / AspNet.Security.OAuth.Providers

OAuth 2.0 social authentication providers for ASP.NET Core
Apache License 2.0
2.35k stars 533 forks source link

how to implement external login provders(linkedin) login using .net core with openidconnect? #804

Closed PriyankaTalapaneni closed 10 months ago

PriyankaTalapaneni commented 10 months ago

tried linkedin login in asp.net core. Added below code in startup

.AddOpenIdConnect(Configuration.GetSection("ExternalLoginConfiguration:LinkedInConfiguration:Scheme").Value, "linkedin", options => { options.SignInScheme = "Identity.External"; options.RequireHttpsMetadata = false; options.ClientId = Configuration.GetSection("ExternalLoginConfiguration:LinkedInConfiguration:ClientId").Value; options.ClientSecret = Configuration.GetSection("ExternalLoginConfiguration:LinkedInConfiguration:ClientSecret").Value; options.CallbackPath = Configuration.GetSection("ExternalLoginConfiguration:LinkedInConfiguration:CallbackPath").Value; options.Authority = "https://www.linkedin.com/"; options.ResponseType = OpenIdConnectResponseType.Code; options.Configuration=new OpenIdConnectConfiguration(); options.Configuration.AuthorizationEndpoint="https://www.linkedin.com/oauth/v2/authorization"; options.Configuration.TokenEndpoint="https://www.linkedin.com/oauth/v2/accessToken"; options.Scope.Clear(); options.Scope.Add("openid"); options.Scope.Add("email"); options.Scope.Add("profile"); options.GetClaimsFromUserInfoEndpoint = true; options.SaveTokens = true; options.Events = new OpenIdConnectEvents() { OnRedirectToIdentityProvider = (ctx) => { // ctx.ProtocolMessage.SetParameter("access_type", "offline"); string username = ctx.Properties.Items["username"];

                                 SetLoginHint(username, ctx);
               return Task.FromResult(0);
           }
       };

   });

and I set IdentityModelEventSource.ShowPII is true.

269588901-479259bb-f409-4c51-99c8-c2913a74ed2f

and getting logs Message: An error was encountered while handling the remote login. Message contains error: 'invalid_client', error_description: 'Client authentication failed', error_uri: 'error_uri is null'

kevinchalet commented 10 months ago

Your question has nothing to do with this repository: you're using the OIDC handler developed and maintained by Microsoft, so you should ask the ASP.NET team: https://github.com/dotnet/aspnetcore