Okta React idToken undefined errors

Hi,
Im having a problem with my okta-react integration and would appreciate any help. Until a few hours ago this integration had been working fine, but know when I login and my app responds to the callback url i get the following error on the page:

TypeError: Cannot read property ‘idToken’ of undefined

This is the only error I can find and there is nothing else in the browser console. Digging into where this error comes from it seems to be related to the handleAuthentication method in the okta-react/Auth object.

Basically the if ( token.idToken ) line, where token is actually undefined. Adding some debug to the babel built version in dist i can see that the call to this._oktaAuth.tokenManager.get('accessToken') is resolving to an array where the first entry is undefined and the second seems to contain an actual value with the relevant tokens (authToken in this case).

I have checked my deps via package.json/package-lock.json and can see that okta-react did upgrade to 1.0.3 and react-auth-js to 2.0.0. But downgrading these didnt seem to make a difference.

Im a bit stuck any suggestions would be appreciated.

thanks

Hi @paran01d

Can you take a look at this thread? - TypeError: Cannot read property 'idToken' of undefined

Seems like another user had similar issue but fixed it.

Hi all,
Id found this post earlier and was not using the withHistory on my ReactRouter (using BrowserRouter ) so initially didn’t think it was related, but after some runs through with the browser js debugger found the problem.

It was that we had enabled outside of react router the HashHistory method of the history module, this was prepending a #/ to the callback url so token_id in the url was being found as /token_id in the okta-auth-js module @

If I get a chance ill try put in a PR that will make it work with HashHistory.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.