amazon-cognito-auth-js icon indicating copy to clipboard operation
amazon-cognito-auth-js copied to clipboard

Cannot read property 'getTokenScopes' of null

Open BleedingDev opened this issue 7 years ago • 0 comments

We have SPA and using refreshToken via Cognito is really problematic as there is no way to check if refreshToken is expired and that probably leads to problem. We logout user when we assume that refreshToken is expired, but that doesn't work when user closed the page and Cognito has session saved in Local Storage.

That leads to uncatched ERROR and then flow is:

  1. Click login button
  2. Get error in console
ERROR TypeError: Cannot read property 'getTokenScopes' of null
    at CognitoAuth.getSpaceSeperatedScopeString (CognitoAuth.js:740)
    at CognitoAuth.getFQDNSignIn (CognitoAuth.js:757)
    at Object.onFailure (auth.effect.ts:127)
    at CognitoAuth.onFailure (CognitoAuth.js:663)
    at XMLHttpRequest.addressState [as __zone_symbol__ON_PROPERTYreadystatechange] (CognitoAuth.js:624)
    at XMLHttpRequest.wrapFn (zone.js:1188)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:4053)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
  1. Redirect back to URL, but no login
  2. User has to click login button again

BleedingDev avatar Oct 01 '18 08:10 BleedingDev