Facing issues in migrating from ADAL JS to MSAL JS

834 views Asked by At

Hope you all are safe & sound, I was migrating my angular app authentication from ADAL JS to MSAL JS.

In ADAL JS, I have my ADAL Config as follows and the authentication works as expected:

adalConfig: {
    tenant: 'GUID',
    clientId: 'GUID',
    redirectUri: window.location.origin
    ......
    ...... // other properties
 }

In MSAL Config I tried to set the same properties in app.module.ts

MsalModule.forRoot({
      auth: {
          clientId: "GUID", // Same as the client ID of ADAL JS
          authority: https://login.microsoftonline.com/<tenant GUID>/, // Same as the tenant GUID of ADAL JS
          redirectUri: OAuthSettings.redirectUri, // This is your redirect URI
      },
      cache: {
        cacheLocation: 'localStorage',
       // storeAuthStateInCookie: true, // set to true for IE 11
    }

However I keep on getting this error

"Please set the correlationId as a valid guid"

I tried looking at this documentation from Microsoft, but it mentions nothing about the authority.

Any help would be highly appreciated.

1

There are 1 answers

0
unknown On

correlationId would be seen in MSAL logs. As the doc shows, correlationId is a unique identifier, used to map the request with the response for debugging purposes.

You could try the code from this link:

MsalModule.forRoot({
    clientID: '00000000-0000-0000-0000-000000000000',
    authority: "https://login.microsoftonline.com/common/",
    validateAuthority: true,
    redirectUri: window.location.origin,
    cacheLocation: 'localStorage',
    postLogoutRedirectUri: window.location.origin,
    navigateToLoginRequestUrl: false,
    popUp: false,
    unprotectedResources: ["https://www.microsoft.com/en-us/"],
    protectedResourceMap: protectedResourceMap,
    logger: loggerCallback,
    correlationId: "1000",
    level: LogLevel.Info,
    piiLoggingEnabled: true
})
....