SyntaxError: Unexpected token e in JSON at position 0 at JSON.parse (<anonymous>) at t.getIdTokenCredential
See original GitHub issuePlease 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:
- Created 3 years ago
- Comments:9 (4 by maintainers)
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