How to add Response_type id_token+code in login url in angular using msadal library

759 views Asked by At

We are using msadal librabry for Azure ad B2C login, now I want to add response_type in https://login.microsoftonline.com/common/oauth2/authorize url while user login.

below is code used for login

 if (!this.msAdal.isAuthenticated && !environment.isTestEnvironment) {
                this.msAdal.login();
            }

used MsAdalAngular6Service library for msadal

I have check adal.js library file, in this for login method response type id_token is set as hardcoded, so I think we can not assign response type in msadal, so what will be the solution if I want to pass response type as code?

1

There are 1 answers

6
unknown On

Please try to use oidc-client-js library for Azure AD B2C, refer to this link. You can find the accompanying sample project here.

In 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"
}