Microsoft-authentication-library-for-js: SyntaxError: Unexpected token e in JSON at position 0 at JSON.parse (<anonymous>) at t.getIdTokenCredential

Created on 29 Oct 2020  路  9Comments  路  Source: AzureAD/microsoft-authentication-library-for-js

Please follow the issue template below. Failure to do so will result in a delay in answering your question.

Library

Important: Please fill in your exact version number above, e.g. [email protected].

Framework

React

Description

Got a syntax error while trying to login
Uncaught (in promise) SyntaxError: Unexpected token e in JSON at position 0
at JSON.parse ()
at t.getIdTokenCredential (index.d9b6c51d.js:2)
at t.e.getSpecificCredential (index.d9b6c51d.js:2)
at index.d9b6c51d.js:2
at Array.forEach ()
at t.e.getCredentialsFilteredByInternal (index.d9b6c51d.js:2)
at t.e.getCredentialsFilteredBy (index.d9b6c51d.js:2)
at t.e.readRefreshTokenFromCache (index.d9b6c51d.js:2)
at t. (index.d9b6c51d.js:2)
at index.d9b6c51d.js:2

Error Message

Uncaught (in promise) SyntaxError: Unexpected token e in JSON at position 0
at JSON.parse ()
at t.getIdTokenCredential (index.d9b6c51d.js:2)
at t.e.getSpecificCredential (index.d9b6c51d.js:2)
at index.d9b6c51d.js:2
at Array.forEach ()
at t.e.getCredentialsFilteredByInternal (index.d9b6c51d.js:2)
at t.e.getCredentialsFilteredBy (index.d9b6c51d.js:2)
at t.e.readRefreshTokenFromCache (index.d9b6c51d.js:2)
at t. (index.d9b6c51d.js:2)
at index.d9b6c51d.js:2

Security

  • [ ] Is this issue security related?

Regression

  • [X] Did this behavior work before?
    Version: 2.2.0
    I think so.. this is the first time I've seen this error since upgrading to 2.4.1 from 2.2.0

    MSAL Configuration

    const publicClientApp = new PublicClientApplication({
      auth: {
        clientId: this.clientId,
        authority: this.authority,
        redirectUri: this.loginRedirectUri,
        postLogoutRedirectUri: this.postLogoutRedirectUri
      },
      cache: {
        cacheLocation: "localStorage",
        storeAuthStateInCookie: isIEOrOldEdge // https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/1188#issuecomment-634281307
      },
      system: {
        tokenRenewalOffsetSeconds: 60,
        iframeHashTimeout: 30000, // iframe is used to refresh the refresh_token as it has a 24h lifetime
        loggerOptions: {
          loggerCallback: MsalAuthContext.msalLoggerCallback,
          piiLoggingEnabled: false,
          logLevel: LogLevel.Verbose
        }
      }
    });

Reproduction steps

// Provide relevant code snippets here.
// For Azure B2C issues, please include your policies.

Expected behavior

No error

Browsers/Environment

  • [X] Chrome
  • [ ] Firefox
  • [ ] Edge
  • [ ] Safari
  • [ ] IE
  • [ ] Other (Please add browser name here)
bug fix-in-progress msal-browser

Most helpful comment

Please try using 2.5.2 if you are having issues. If this does not fix your problem comment here.

All 9 comments

Let me know if you need any more info from me regarding state of localStorage etc

We are also seeing this in 2.4.1

@hectormmg Can you port the fix you did for v1 here? Looks like the same issue.

Getting the same error in 2.5.1

We also encountered this problem.

Is there a work around in the meantime?

Please try using 2.5.2 if you are having issues. If this does not fix your problem comment here.

It is working for me now with version 2.5.2. Thank you @pkanher617

Closing as #2527 fixes this PR.

Was this page helpful?
0 / 5 - 0 ratings