Invalid state error for react-native-auth0 passwordless

  • Which SDK this is regarding: react-native-auth0
  • SDK Version: 2.13.1
  • Platform Version: iOS 15.5
  • Code Snippets/Error Messages/Supporting Details/Screenshots:

Hi, I’ve tried to set up a passwordless flow with email and magic links. After I set up all the needed things in the management dashboard, I tried to start implementing it in the react-native app. The whole flow seems to work, but I always got an error about “Invalid state”. I’ve checked the package and log state memorized by SDK and this one which comes from the magic link, they’re different. How can I manage it properly to log in? And the second question. Should the user close webview manually or should it be closed automatically after getting success?

    const auth0Client = new Auth0({
      domain: "...",
      clientId: "...", 
    }),
    try {
      const response = await auth0Client.webAuth.authorize(
        {
          scope: 'openid profile',
        },
        { ephemeralSession: true },
      );
      console.log('🚀 response', response);
    } catch (error) {
      console.log('🚀 error', error);
    }
 LOG  🚀 ~ file: index.js ~ line 122 ~ WebAuth ~ returnagent.newTransaction ~ resultState hKFo2SBHb1YtSVdoaGFpcGRSWUNmV2FLVWdNaGxaemV4aEIwYqFupWxvZ2luo3RpZNkgMWdqN28yWmVTN0pTX0xlaDVNdmxMYnNGN3NfdkVoNXejY2lk2SBoeENQeHd0dWg5WTV3bEJodld6eXIxSjBTRDliM2FONw
 LOG  🚀 ~ file: index.js ~ line 123 ~ WebAuth ~ returnagent.newTransaction ~ expectedState B5GjGU4ckLrbSkHYacX7OWIk1H9DrCsyHTZDeUfWdKc
 LOG  🚀 error [a0.state.invalid: Invalid state received in redirect url]

Hello @hubert.stemplewski! Welcome to the community!

This is a very common issue. Here is a solved post regarding Invalid State Errors. I will add an additional thread that discusses the topic as well if the first did not solve your problem.

I hope this helps!

Best,
Alex