【问题标题】:Identity Server 4 External Provider Claims ExtensionIdentity Server 4 外部提供者声明扩展
【发布时间】:2020-12-07 13:27:54
【问题描述】:

我在 ASP.NET Core 应用程序中配置了身份服务器 4。除了打开和配置文件范围外,我还希望获得登录用户的生日作为声明。我对以下配置没有运气

services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
                .AddFacebook(options =>
                {
                    options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
                    options.AppId = "XXX";
                    options.AppSecret = "XXX";
                    options.SaveTokens = true;
                    options.Scope.Add("user_birthday");
                    options.Fields.Add("birthday");
                })

知道为什么这不起作用吗?

OIDC 客户端请求配置

var config = {
    authority: "https://localhost:44330",
    client_id: "ff-client",
    redirect_uri: "https://localhost:5003/callback.html",
    response_type: "id_token token",
    scope:"openid profile gateway identity",
    post_logout_redirect_uri: "https://localhost:5003/index.html",
    acr_values: "idp:Facebook",
    loadUserInfo: true,
};

【问题讨论】:

标签: asp.net-core identityserver4 facebook-oauth


【解决方案1】:

检查用户是否授予访问权限。参考:https://developers.facebook.com/docs/graph-api/using-graph-api/common-scenarios/#how-to-get-an-access-token

如果您想确认用户已授予您的应用 user_birthday 权限,您可以在 /{user-id}/permissions 边缘执行 GET 操作。假设用户授予权限,API 响应如下所示:

示例响应

{
  "data": [
    {
      "permission":"user_birthday",
      "status":"granted"
    }
  ]
}

【讨论】:

    猜你喜欢
    • 2021-03-14
    • 2020-06-21
    • 2017-08-02
    • 2014-04-01
    • 2015-03-24
    • 2021-03-06
    • 2019-05-06
    • 1970-01-01
    • 2019-06-07
    相关资源
    最近更新 更多