Python Authlib Flask-如何撤销令牌/注销 [英] Python authlib flask - how to revoke token / logout
问题描述
在当前情况下,我的烧瓶应用程序可能是唯一使用Oauth服务器的应用程序.
在这种情况下,我想让我的注销按钮实际上撤销访问令牌.
但是如何使用authlib flask集成来做到这一点呢?
我是否只需要使用 revoke_token()
来设置新的 OAuth2Session
?
我认为 FlaskRemoteApp
中没有隐藏的内容吗?
而且我不认为Flask注册表需要 revoke_token_url
或类似的东西?
In my current situation my flask app could be the only one using the Oauth server.
In that case I'd like to have my logout button actually revoke the access token.
But how to do that using the authlib flask integration?
Do I have to set up a new OAuth2Session
just to use revoke_token()
?
I don't think there is a hidden one inside FlaskRemoteApp
?
And I don't think the flask registry takes a revoke_token_url
or anything like that?
欢迎任何建议.
推荐答案
好的,这是使用现有flask注册表对我有用的代码.
Ok, here is the code that works for me using the existing flask registry.
from authlib.integrations.requests_client import OAuth2Session
client = OAuth2Session(oauth.myOauth.client_id,
oauth.myOauth.client_secret,
scope=oauth.myOauth.client_kwargs['scope'])
client.revoke_token(app.config['OASERVER'] + '/oauth2/revoke',
token=session['oatoken']['access_token'])
这篇关于Python Authlib Flask-如何撤销令牌/注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!