authlib
authlib copied to clipboard
Change token in session
Hello!
I don't need to add a token to the store. I want to set the updated token in request.session. Is it possible?
I use this demo https://github.com/authlib/demo-oauth-client/blob/master/fastapi-twitter-login/app.py
async def update_token(token, refresh_token=None, access_token=None):
# I want this
# request.session['token'] = token
await asyncio.sleep(0)
oauth = OAuth()
oauth.register(
...,
update_token=update_token
)
I don't need to add a token to the store.
Does this answer your question?
https://github.com/lepture/authlib/blob/0ad753cbe39e3cb5bee33ef93b7497020a33dea1/docs/client/frameworks.rst?plain=1#L261-L298
Not having a single source of truth will make handling the token, especially its lifecycle management, very hard, unless you make that session a global variable, which is an equally bad practice.
@codespearhead
Thanks for the answer!
I'm using only gitlab oauth2. I just need to submit requests to gitlab through my application.
This is a simple application that should create reports for the user. Is it possible to manage without a database?