【问题标题】:Obtaining Refresh Token from lepture/Authlib through Authorization Code通过授权码从lepture/Authlib获取Refresh Token
【发布时间】:2018-12-20 16:08:21
【问题描述】:

我正在尝试开发一个使用 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)    

【问题讨论】:

    标签: oauth-2.0 access-token refresh-token authlib


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2018-08-01
      • 2020-01-31
      • 2016-11-27
      • 2019-03-21
      • 1970-01-01
      • 2020-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多