MSAL with angular fails to authenticate - fails while attempting to discover the instance

Viewed 1093

While using SSO to sign on Azure using MSAL with Angular, I get redirected this URL: https://login.microsoftonline.com/common//discovery/instance?api-version=1.1&authorization_endpoint=https://login.microsoftonline.com/{tenant}/{organization}.onmicrosoft.com/{policyName}/oauth2/v2.0/authorize endpoint.

... and the response is - 400 bad request error or an invalid_request (in the xhr)

A curl comes back with this error: "error":"invalid_request","error_description":"AADSTS50050: The request is malformed: invalid format for 'authorization_endpoint'

Why would this happen for new users?

update:

MsalModule.forRoot(
      {
        auth: {
          ...
          validateAuthority: false,
          ...
        },
...

setting validateAuthority: false resolved this issue for now. However, setting validateAuthority should not cause problems - this is just a workaround.

1 Answers

If you are using Azure AD, try to change your authorization_endpoint to

https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize

Policy name is always used for Azure AD B2C, format like: https://{your-B2C-tenant-name}.b2clogin.com/{organization}.onmicrosoft.com/{policyName}/oauth2/v2.0/authorize.

Related