OAuth client: CSRF Warning! State not equal in request and response (mismatching_state)
The state sent back by the provider is not the one the client stored, so the login is aborted as a possible CSRF attack.
CSRF Warning! State not equal in request and responseState not equal in request and responseOAuth state mismatch session Meaning
Libraries such as Authlib, requests-oauthlib and Flask-Dance keep state in the user's session. If the session cookie is missing, expired, or belongs to another host or worker, the check fails.
Common causes
- Session cookie not sent on the callback (SameSite, host mismatch)
- Multiple app instances without shared session storage
- User opened the login in two tabs
- Secret key changed between workers or restarts
⚡ Quick fix
- Use the same host name for start and callback
- Share the session secret and storage between workers
- Keep one login flow per tab
Detailed fix by platform
Flask
- Set a fixed
SECRET_KEYandSESSION_COOKIE_SAMESITE="Lax"; use one domain for the whole flow
How to diagnose
- Cookie — Sent on callback?
- Workers — Same secret?
- Tabs — Parallel logins?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Most viewed in Authentication
- disallowed_useragent Google OAuth: Error 403: disallowed_useragent (sign-in from an embedded WebView)
- Access blocked: has not completed the Google verification process Google OAuth: Error 403: access_denied — The developer hasn't given you access to this app / has not completed the Google verification process
- Missing Authentication Token {"message":"Missing Authentication Token"} / No authorization token was found
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 2 Dec 2026