通过授权码从 lepture/Authlib 获取刷新令牌

Obtaining Refresh Token from lepture/Authlib through Authorization Code

我正在尝试开发一个使用 Authlib OAuth2 服务器获取刷新令牌的简单工具,但示例服务器 here 不发出刷新令牌。当我打印令牌时,我得到以下信息:

{'access_token': '....', 'scope': 'profile', 'token_type': 'Bearer', 'expires_in': 864000, 'expires_at': 1532191887}

流程是引用的授权码;首先我处理同意部分:

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)    

添加 OAUTH2_REFRESH_TOKEN_GENERATOR=True 的配置,在提交中添加:

https://github.com/authlib/example-oauth2-server/commit/4f2f48cc3e74b631d9c4c3bdf8558da3de7365a2

查看文档:https://docs.authlib.org/en/latest/flask/2/