Microsoft-authentication-library-for-js: TypeError: Cannot read property 'indexOf' of undefined

Created on 17 May 2019  路  9Comments  路  Source: AzureAD/microsoft-authentication-library-for-js

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Browser:

  • [ x] Chrome version XX
  • [ ] Firefox version XX
  • [ ] IE version XX
  • [ ] Edge version XX
  • [ ] Safari version XX

Library version


Library version: 1.0.0


## Current behavior
Using acquireTokenPopup, I decline to grant consent, and choose the option to be "return to the application without granting consent". The following error is then generated:
TypeError: Cannot read property 'indexOf' of undefined
  at e.IsInteractionRequired (msal.min.js:17)
  at e.saveTokenFromHash (msal.min.js:17)
  at e.processsCallBack (msal.min.js:17)
  at e.handleAuthenticationResponse (msal.min.js:17)
  at new e (msal.min.js:17)
  at 


## Expected behavior
A proper error should be thrown with appropriate errorCode to be handled by the application.


## Minimal reproduction of the problem with instructions
Call acquireTokenPopup asking for a scope that requires admin consent, and then at the consent screen, choose "Return to the application without granting consent" that appears in the consent page (shown when you are not logged-in as an admin in your homedirectory).


Most helpful comment

@johnsardine We are also tracking 'Back' button error separately, I believe we have the fix, will update the PR once we are able to.

All 9 comments

@keystroke Thanks for submitting this and bringing it to our attention.
@sameerag can you confirm this is related to #706 and may be resolved by #707

I am yet to debug this but my thinking aligns with yours. I will update once I confirm that theory.

@keystroke @DarylThayil This is a different issue than #706. I see us throwing the right server error but I also see "Cannot read property 'indexOf' of undefined" error too. Will update with my analysis some time next week.

I am also experiencing this issue using the following parameters on my loginPopup method

{
  prompt: 'select_account',
  hint: 'preferred_username',
  graphScopes: [
    'openid',
  ],
}

Once the popup opens, I just click Back and an exception is thrown

TypeError: Cannot read property 'indexOf' of undefined
    at UserAgentApplication.isInteractionRequired (UserAgentApplication.js?6444:788)
    at UserAgentApplication.saveTokenFromHash (UserAgentApplication.js?6444:1507)
    at UserAgentApplication.processCallBack (UserAgentApplication.js?6444:1042)
    at UserAgentApplication.handleAuthenticationResponse (UserAgentApplication.js?6444:1144)
    at new UserAgentApplication (UserAgentApplication.js?6444:124)

@johnsardine We are also tracking 'Back' button error separately, I believe we have the fix, will update the PR once we are able to.

@sameerag I just confirmed the "back button" version of this issue still exists in version 1.0.2 on chrome.

@keystroke The release 1.0.2 does not have this fix. I will update the PR in this issue once we have it available.

@sameerag I have an update on this. The error we are seeing from the server is of the format: #error=access_denied&error_subcode=cancel&state=**

The index of error is happening because there is no error description in the hash and msal js is trying to read from it. That can be remedied easily but If we fix only msal js, it still may not be the comprehensive error message in the context.

I am working with the server team to check if they will help with better messaging in this case. Since they control the screens and generate the above errors, we would need their changes as well.

Will update this issue with a PR once that is concluded.

811 fixes this and currently merged to dev.

@keystroke Please pull in the dev branch if you want to quickly test this. This handles the undefined error and you see a server error thrown. Regarding adding a specific error type for these cases, I am talking to the service guys to understand what is feasible and will have a new PR for that later.

Closing for now. Please open a new issue if you believe the current changes are not sufficient in your case.

Was this page helpful?
0 / 5 - 0 ratings