Mismatch_state error when use fastapi with google oauth #11732
Unanswered
nghianguyen1708
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
When I try to login with gg through the @app.get("/auth/google") API, it route me to the gg login page, after I have chosen an account, it routes me back to my "/auth/google/callback" url with the state and code parameter. However, when it run "authorize_access_token(request)", it returns a authlib.integrations.base_client.errors.MismatchingStateError: mismatching_state: CSRF Warning! State not equal in request and response. When I debug the code, it seems that the state return in the url is not found in any of the session key. Has anyone experienced this?
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.111.0
Pydantic Version
2.7.4
Python Version
3.12.4
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions