question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError: Unexpected token e in JSON at position 0 at JSON.parse (<anonymous>) at t.getIdTokenCredential

See original GitHub issue

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

Library

  • msal@1.x.x or @azure/msal@1.x.x
  • @azure/msal-browser@2.4.1
  • @azure/msal-angular@0.x.x
  • @azure/msal-angular@1.x.x
  • @azure/msal-angularjs@1.x.x

Important: Please fill in your exact version number above, e.g. msal@1.1.3.

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 (<anonymous>) at t.getIdTokenCredential (index.d9b6c51d.js:2) at t.e.getSpecificCredential (index.d9b6c51d.js:2) at index.d9b6c51d.js:2 at Array.forEach (<anonymous>) 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.<anonymous> (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 (<anonymous>) at t.getIdTokenCredential (index.d9b6c51d.js:2) at t.e.getSpecificCredential (index.d9b6c51d.js:2) at index.d9b6c51d.js:2 at Array.forEach (<anonymous>) 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.<anonymous> (index.d9b6c51d.js:2) at index.d9b6c51d.js:2

Security

  • Is this issue security related?

Regression

  • 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

  • Chrome
  • Firefox
  • Edge
  • Safari
  • IE
  • Other (Please add browser name here)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
pkanher617commented, Nov 2, 2020

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

1reaction
narva001commented, Nov 3, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: Unexpected token < in JSON at position 0
I experienced this error "SyntaxError: Unexpected token m in JSON at position", where the token 'm' can be any other characters.
Read more >
What Is JSON and How to Handle an “Unexpected Token” Error
Learn what JSON is and how you can deal with errors occurring when parsing JSON data, such as "Unexpected Token < in JSON...
Read more >
How to Fix SyntaxError: Unexpected token < in JSON at ...
This guide will help to fix SyntaxError: Unexpected token < in JSON at position 0 . This guide also applies to these other...
Read more >
Unexpected token u in JSON at position 0 Error in JS
The "Unexpected token u in JSON at position 0" error occurs when we pass an undefined value to the JSON.parse or $.parseJSON methods....
Read more >
Troubleshoot 'Uncaught SyntaxError: Unexpected token u in ...
The 'Uncaught SyntaxError: Unexpected token u in JSON at position 0' error is caused when the client has been asked to execute JSON.parse() ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found