我正在尝试开发一个简单的工具,该工具使用Authlib OAuth2服务器获取刷新令牌,但是示例服务器here不会发布刷新令牌。当我打印令牌时,我得到以下信息:
{'access_token': '....', 'scope': 'profile', 'token_type': 'Bearer', 'expires_in': 864000, 'expires_at': 1532191887}
该流程是授权代码,称为here;首先,我要处理同意部分:
client_id = '...'
client_secret = '.....'
scope = '...'
session = OAuth2Session(client_id, client_secret, scope=scope)
authorize_url = '.../oauth/authorize'
uri, state = session.authorization_url(authorize_url)
然后我尝试获取令牌:
urlset = '.../?code=...&state=...'
access_token_url = '.../oauth/token'
token = session.fetch_access_token(access_token_url,authorization_response=urlset)
答案 0 :(得分:2)
添加OAUTH2_REFRESH_TOKEN_GENERATOR=True
的配置,并在提交中添加:
https://github.com/authlib/example-oauth2-server/commit/4f2f48cc3e74b631d9c4c3bdf8558da3de7365a2
请参阅文档:https://docs.authlib.org/en/latest/flask/oauth2.html#server