Skip to content
New issue

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

(mismatching_state) CSRF Warning! State not equal in request and response. #27

Open
zentixua opened this issue Mar 19, 2023 · 1 comment

Comments

@zentixua
Copy link

zentixua commented Mar 19, 2023

My code

@app.route('/callback')
async def callback():
    logger.info("1")
    try:
        logger.info("2")
        if await discord.authorized:
            logger.info("3")
            return redirect(url_for('index'))
        logger.info("4")
        await discord.callback()
        logger.info("5")
        next_url = session.pop('next_url', '/')
        logger.info("6")
        return redirect(next_url)
    except AccessDenied as e:
        logger.info("7")
        return await render_template('auth_cancel.html')
    except DecodeError as e:
        logger.info(f"callback() error: {e}")
        return await render_template("use_normal_browser.html")


@app.errorhandler(Unauthorized)
async def redirect_unauthorized(e):
    session['next_url'] = request.url
    return await discord.create_session()

(loggers for debug)

Im getting:

2023-03-19 06:32:41,148 - LOGGER - INFO - 1
2023-03-19 06:32:41,149 - LOGGER - INFO - 2
2023-03-19 06:32:41,149 - LOGGER - INFO - 4
2023-03-19 06:32:41,149 - LOGGER - INFO - Some error: (mismatching_state) CSRF Warning! State not equal in request and response.
@zentixua
Copy link
Author

This does not always happen, only the first time - with our user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant