Skip to content
← Back to activity

Public problem

Uncaught (in promise) Error: Invalid state after social login redirect

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

After logging in with a social connection (e.g. Continue with Google), the app threw Uncaught (in promise) Error: Invalid state from handleRedirectCallback in auth0-spa-js. The login itself succeeded, but processing the redirect back failed. This happened when the redirect callback URL still carried the code and state query parameters and the callback ran more than once.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

The fix is to clear the query parameters right inside your onRedirectCallback so the callback cannot be re-processed: call window.history.replaceState({}, document.title, window.location.pathname) in the callback. Multiple reporters confirmed this resolved the Invalid state error. The underlying cause is the SDK re-reading stale code/state params from the URL on a second pass, so stripping them immediately after handling the redirect prevents it. Source: https://github.com/auth0/auth0-spa-js/issues/245

Source: https://github.com/auth0/auth0-spa-js/issues/245