angular - 如何使用 msadal 库在登录 url 中添加 Response_type id_token+code
问题描述
我们正在使用 msadal 库进行 Azure 广告 B2C 登录,现在我想在用户登录时在https://login.microsoftonline.com/common/oauth2/authorize url 中添加 response_type。
下面是用于登录的代码
if (!this.msAdal.isAuthenticated && !environment.isTestEnvironment) {
this.msAdal.login();
}
为 msadal 使用了 MsAdalAngular6Service 库
我检查了 adal.js 库文件,在此登录方法响应类型 id_token 设置为硬编码,所以我认为我们不能在 msadal 中分配响应类型,那么如果我想将响应类型作为代码传递,解决方案是什么?
解决方案
请尝试使用oidc-client-js
Azure AD B2C 库,请参阅此链接。您可以在此处找到随附的示例项目。
在oidc-settings.json:
{
"client_id": "47ea6724-b21f-46de-9d17-7425920f77e4",
"baseUrl": "http://localhost:4200",
"signupSigninPolicy": "b2c_1_signupandsignin",
"tenantName": "taithienbo",
"response_type": "id_token token", // set response_type here
"loadUserInfo": false,
"response_mode": "fragment",
"scope": "https://taithienbo.onmicrosoft.com/mywebapi/user_impersonation openid profile",
"editProfilePolicy": "B2C_1_a_profile_edit"
}
推荐阅读
- python - 在 elif 语句中调用函数
- python - Pip 未安装在 virtualenv 中
- c# - 将 Moment.Js 与 MVC/.NET Razor 视图结合使用
- ef-core-2.1 - 使用 EF Core 导入数百万行
- rest - 从后端动态加载可变列表(fe. for recyclerview)。可能用于 Facebook、GMail、9GAG、Instagram 和 co
- python - 为什么除了命令末尾包含“--user”外,pip install 的权限被拒绝?
- ruby-on-rails - Rails 5.1.6 无法启动:main:Object 的未定义局部变量或方法“config”
- javascript - 如何将存储在使用推送提示创建的数组中的值相加
- docker - Docker 工具箱错误:“设置环境”步骤中似乎出了点问题
- ionic3 - 使用 ionic Pro 构建 IOS