asp.net-core - Identity Server 4 外部提供者声明扩展
问题描述
我在 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,
};
解决方案
检查用户是否授予访问权限。参考: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"
}
]
}
推荐阅读
- python-3.x - 无法在 Windows 上运行任何 pipenv 命令
- excel - 不使用计数器进行优化
- javascript - 从 Javascript 对象数组创建 HTML 列表
- node.js - 如何修改 smartly.ai 模板
- c# - 电子交易:请求访问令牌,我得到签名无效
- github - Github-我们不能用相同的代码创建两个存储库吗
- java - 部分回收者按日期查看照片
- c++ - VS Code C++ 自动完成用户定义不起作用
- ruby-on-rails - 如何从 elasticsearch-rails 调用 _count?
- python - 协助 discord.AuditLogAction