question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

handleCallback - Cannot read property 'toString' of undefined error

See original GitHub issue

Visits to our tenant’s domain that result in an unauthorized error with an error description of wrong email or verification code result in a redirect to our callback url that ends up producing the following unhandled error from within nextjs-auth0 of Cannot read property 'toString' of undefined.

The callback url that produces this error is:https://{auth0-domain-here}/api/auth/callback#error=unauthorized&error_description=Wrong email or verification code

related to: https://github.com/auth0/nextjs-auth0/issues/371, but the solution there is not the issue as the new api/auth routes are being used.

I’d expect these kinds of things to be more gracefully handled with perhaps a redirect to api/auth/logout.

We are using passwordless authentication with magic link and we are on v1.3.0.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
adamjmcgrathcommented, May 27, 2021

I suppose I can try to handle this error in a custom way on our end or check if there is an active session and redirect to the app if so.

Yep checks.state argument is missing is the correct error in this scenario, since you’re visiting the callback page without any state cookies to check (they were removed in your previous successful login)

1reaction
adamjmcgrathcommented, May 11, 2021

Hi @jaredgalanis - it’s not an unhandled exception, but I agree the message should be better.

Per our discussion in https://github.com/auth0/nextjs-auth0/issues/346 - this SDK doesn’t support embedded Passwordless.

It only supports the Universal Login Page, if you were using the Universal Login Page and initiating the login from the application, you’d be using response_mode: query and your errors would be coming back from the authorization server on the query parameters (eg https://{auth0-domain-here}/api/auth/callback?error=unauthorized&error_description=Wrong email or verification code) rather than the fragment (per your example)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'toString' of undefined error · Issue #371 ...
Description After authenticating with auth0 and being redirected back to /api/callback a Cannot read property 'toString' of undefined error ...
Read more >
Why do I get Cannot read property 'toString' of undefined
I've added a log at the end of the slug function. console.log(result); return result; };. This prints the results and then throws error....
Read more >
Cannot read property 'toString' of undefined - Web
Description Hi, I am using Zoom SDK version 1.9.7. When I join the meeting, I have this error: Here is my code on...
Read more >
Cannot authenticate via Magic Link - Auth0 Community
I'm trying to configure logic via magic link. I've successfully setup the passwordless connection and my custom email provider such that the ...
Read more >
TypeError: Cannot read property 'toString' of undefined
Hi all. I noticed a day or so ago, I have stopped getting some values. The error is "TypeError: Cannot read property 'toString'...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found