Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Feature Request] Add the Flask 'request' object to the dash callback context for background callbacks #2636

Closed
JamesKunstle opened this issue Aug 30, 2023 · 2 comments

Comments

@JamesKunstle
Copy link

I'm using Flask-Login to manage user sessions. Getting user preferences from the OAuth content server can be a long running task, so I wanted to use a background callback. However, background callbacks don't have the 'request' or Flask-Login 'current_user' proxies available because they're not responding as a Flask thread.

If the user session cookie value was available in background callbacks I could make authenticated requests in the Celery task, which would remove a lot of hacky multi-callback message passing.

@JamesKunstle
Copy link
Author

Update: For anyone looking for a solution, you can pass the 'request=flask.request' object into background callbacks and that seems to work.

https://community.plotly.com/t/how-to-read-cookies-inside-a-background-callback/70224/11

@alexcjohnson
Copy link
Collaborator

Going to copy your workaround comment into duplicate issue #2235 and close - thanks!

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

No branches or pull requests

2 participants