Facebookにログインできるようにidentityserverを設定しようとしています。 facebook.Theのmvcアプリからユーザー情報のいずれかを取得することはできません以外はすべて正常に動作しますgivennameと姓のクレームが期待されています。私はpublic_profileにスコープを追加しましたが、それを戻しません。Identity Server 3を使用した外部ログイン - facebookから指定された名前のクレームを設定する
多くの研究の末、これを行うためにUserServiceをセットアップする必要があるようですが、これを行う方法がわかりません。
助けていただければ幸いです。ここで
はidenityサーバアプリのstatupで外部プロバイダを設定するには、私のコードです:
private void ConfigureIdenityProviders (IAppBuilder app, string signInAsType)
{
var facebookOptions = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions
{
AuthenticationType = "Facebook",
Caption = "Sign in with Facebook",
SignInAsAuthenticationType = signInAsType,
AppId = "xxxxxxxxxxxx",
AppSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
Provider = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationProvider()
{
OnAuthenticated = (context) =>
{
// Problem here - there is no last_name returned
JToken lastname;
if (context.User.TryGetValue("last_name", out lastname))
{
context.Identity.AddClaim(new System.Security.Claims.Claim(IdentityServer3.Core.Constants.ClaimTypes.FamilyName, lastname.ToString()));
}
context.Identity.AddClaim(new System.Security.Claims.Claim("role", "Guest"));
return Task.FromResult(0);
}
}
};
facebookOptions.Scope.Add("public_profile");
facebookOptions.Scope.Add("email");
app.UseFacebookAuthentication(facebookOptions);
}