[Python] Google oAuth breaks when using multiple gunicorn workers

Discussão em 'Python' iniciado por Stack, Abril 10, 2025.

  1. Stack

    Stack Membro Participativo

    When I try to login to my website using Google, I will get this error (sometimes). "oauthlib.oauth2.rfc6749.errors.MismatchingStateError: (mismatching_state) CSRF Warning! State not equal in request and response."

    The error happens at this if statement:

    @app.route('/callback')
    def callback():
    flow.fetch_token(authorization_response=request.url)

    if not session["state"] == request.args["state"]:
    abort(500) # State does not match!


    What I think is happening is that multiple workers create different session tokens or something like that. Im not to familiar with web stuff.

    I tried changing the amount of workers to 1 and the site works fine. Which is what proves my theory of whats wrong. I just dont know how to fix it.

    Continue reading...

Compartilhe esta Página