We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting an error oauthlib.oauth2.rfc6749.errors.MismatchingStateError: (mismatching_state) CSRF Warning! State not equal in request and response
oauthlib.oauth2.rfc6749.errors.MismatchingStateError: (mismatching_state) CSRF Warning! State not equal in request and response
@router.get("/github", response_class=RedirectResponse) async def github(): authorization_url, state = github_oauth.authorization_url(authorization_base_url) return authorization_url @router.get("/callback") async def authorize(code: str): github_oauth.fetch_token( token_url, client_secret=client_secret, authorization_response=code ) r = github_oauth.get("https://api.github.com/user")
but when I log state inside `github` function it logs same as in the query param `state` of the callback url
The text was updated successfully, but these errors were encountered:
Hi, Can you tell us how are you creating github_oauth and when? We can't see how are you using the state variable in this example ? Thanks
github_oauth
state
Sorry, something went wrong.
I experienced a similar issue re: not being able to exchange tokens due to the state parameter. Turns out it's because the OAuthSession keeps track of the state it generated earlier and then there is validation against the authorization_response if that parameter is used.
OAuthSession
authorization_response
You can by-pass the state validation by passing in the code parameter versus the authorization_response parameter, i.e.
code
oauth_client.fetch_token(token_url, client_secret=client_secret, code=code)
No branches or pull requests
Getting an error
oauthlib.oauth2.rfc6749.errors.MismatchingStateError: (mismatching_state) CSRF Warning! State not equal in request and response
The text was updated successfully, but these errors were encountered: