首页 > 解决方案 > 如何使用 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 中分配响应类型,那么如果我想将响应类型作为代码传递,解决方案是什么?

标签: angularazure-active-directorymulti-tenantms-adal-angular

解决方案


请尝试使用oidc-client-jsAzure 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"
}

推荐阅读