Safari Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'response.tokenType')
See original GitHub issueDescribe the bug Whenever I try to get an access token with LoginType Redirect in Safari 13, I end up receiving the following error: Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating ‘response.tokenType’).
I’m getting the same behavior with the sample app, LoginType Popup however does seem to work.
Additionally I found this error in the session state:
- msal.omitted-application-id.error.description
- AADSTS50058: A silent sign-in request was sent but no user is signed in. The cookies used to represent the user’s session were not sent in the request to Azure AD. This can happen if the user is using Internet Explorer or Edge, and the web app sending the silent sign-in request is in different IE security zone than the Azure AD endpoint (login.microsoftonline.com).
To Reproduce Steps to reproduce the behavior:
- Follow sample app setup
- Open Safari
- Browse to localhost:3000
- Click “Redirect Sample”
- Click “enable redirect”
- Log in with your Azure AD credentials
- Once you’re back in the sample app, click get access token and the error should occur
Expected behavior Receive an access token similarly to when using LoginType Popup.
Desktop (please complete the following information):
- OS: macOS Catalina 10.15.2
- Browser Safari
- Version Version 13.0.4 (15608.4.9.1.3)
Additional context package json dependencies:
"dependencies": {
"msal": "1.2.0",
"react-aad-msal": "2.2.7",
"react-scripts": "^3.3.0",
"react": "16.12.0",
"react-redux": "7.1.3",
"react-dom": "16.12.0"
}
Logs:
[Log] [HMR] Waiting for update signal from WDS... (0.chunk.js, line 52259)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:06 GMT:1.2.0-Info Returned from redirect url" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:06 GMT:1.2.0-Info Processing the callback from redirect response" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:06 GMT:1.2.0-Info State status:true; Request type:LOGIN" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:06 GMT:1.2.0-Info State is right" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:06 GMT:1.2.0-Info Fragment has id token" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:06 GMT:1.2.0-Info Token is already in cache for scope:omitted-application-id" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:12 GMT:1.2.0-Verbose Token is not in cache for scope:openid" (main.chunk.js, line 921)
[Log] [MSAL] – ":1.2.0-Verbose renewing accesstoken" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:12 GMT:1.2.0-Verbose renewToken is called for scope:openid" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:12 GMT:1.2.0-Info Add msal frame to document:msalRenewFrameopenid" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:12 GMT:1.2.0-Verbose Renew token Expected state: guid" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:12 GMT:1.2.0-Verbose Set loading state to pending for: openid:guid" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:12 GMT:1.2.0-Info LoadFrame: msalRenewFrameopenid" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:13 GMT:1.2.0-Info Add msal frame to document:msalRenewFrameopenid" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:13 GMT:1.2.0-Info Returned from redirect url" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:13 GMT:1.2.0-Info Processing the callback from redirect response" (main.chunk.js, line 921)
[Log] [MSAL] – "Sun, 22 Dec 2019 19:21:13 GMT:1.2.0-Info State status:true; Request type:RENEW_TOKEN" (main.chunk.js, line 921)
[Error] Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'response.tokenType')
(anonymous function) (0.chunk.js:12049)
promiseReactionJob
Apparently this points to the following piece of code:
import { AuthResponse } from 'msal';
import { TokenType } from './Interfaces';
export class AccessTokenResponse {
public accessToken = '';
public scopes: string[] = [];
public expiresOn: Date;
public state = '';
constructor(response: AuthResponse) {
if (response.tokenType !== TokenType.AccessToken) { // error occurs here
throw new Error(
`Can't construct an AccessTokenResponse from a AuthResponse that has a token type of "${response.tokenType}".`,
);
}
this.accessToken = response.accessToken;
this.expiresOn = response.expiresOn;
this.scopes = response.scopes;
this.state = response.accountState;
}
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Unhandled promise rejection: TypeError: undefined is not an ...
The error is received at the line where (response) => response.json() is. Here is the fetch request: export const loginService = (user) => ......
Read more >Safari Unhandled Promise Rejection - Bountysource
Safari Unhandled Promise Rejection : TypeError: undefined is not an object (evaluating 'response.tokenType')
Read more >undefined is not an object (evaluating 'response.data')
But I always get this error when submiting a form. Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'response.data'). Any ideas ......
Read more >How to resolve an ' [unhandled promise rejection: typeerror ...
Lets break it down bit by bit: [code][unhandled promise rejection: typeerror: undefined is not an object (evaluating '_expopermissions.permissions.getasync.
Read more >SyntaxError: Unexpected token - JavaScript - MDN Web Docs
This might be a simple typo. Examples. Expression expected. For example, when chaining expressions, trailing commas are not allowed.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Should be resolved by #238
Hi @AndrewCraswell any update on working with @sameerag from the MSAL.js team to update this library to use PKCE? It seems that with the latest versions of Chrome(84) blocking 3rd party cookies, PKCE is fast becoming the only user friendly doing the MSAL auth. FYI: @alex-mason-by and @dj-jovic-by