4
我正在使用dotnet核心我想在網站上設置LinkedIn身份驗證,因爲LinkedIn沒有默認身份驗證構建器,如facebook,google和twitter我決定使用泛型實現,如下所示:AddOAuth linkedin dotnet核心2.0
services.AddAuthentication().AddOAuth("LinkedIn",
c =>
{
c.ClientId = Configuration["linkedin-app-id"];
c.ClientSecret = Configuration["linkedin-app-secret"];
c.Scope.Add("r_basicprofile");
c.Scope.Add("r_emailaddress");
c.CallbackPath = "/signin-linkedin";
c.AuthorizationEndpoint = "https://www.linkedin.com/oauth/v2/authorization";
c.TokenEndpoint = "https://www.linkedin.com/oauth/v2/accessToken";
c.UserInformationEndpoint = "https://api.linkedin.com/v1/people/~:(id,formatted-name,email-address,picture-url)";
})
我遇到問題,因爲GetExternalLoginInfoAsync()爲空,查找身份ASP.net核心源,是因爲providerkey爲空。
從asp.net核心代碼摘自:
var providerKey = auth.Principal.FindFirstValue(ClaimTypes.NameIdentifier);
var provider = items["LoginProvider"] as string;
if (providerKey == null || provider == null)
{
return null;
}
的問題是我在哪裏可以在ClaimTypes.NameIdentifier添加到LinkedIn要求?