首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用lepture/authlib获取refresh_token

使用lepture/authlib获取refresh_token
EN

Stack Overflow用户
提问于 2018-02-21 21:58:20
回答 1查看 1.5K关注 0票数 2

我正在使用Authlib,并试图从Hydra服务器获取refresh_token。我有以下代码:

代码语言:javascript
复制
from authlib.client import OAuth2Session

client_id = "my-client"
client_secret = "client secret"
token_url = "https://myhydraserver/token"
scope = 'openid email profile offline'
session = OAuth2Session(client_id, client_secret, scope=scope)

token = session.fetch_access_token(token_url)
print(token)

这将打印出来

代码语言:javascript
复制
{'access_token': 'the-token', 'expires_in': 3599, 'scope': '', 'token_type': 'bearer', 'expires_at': 1519224804}

从文档中,我看到有一个函数可以从refresh_token获取访问令牌,但是找不到一种首先获取refresh_token的方法。我该怎么去买一个refresh_token呢?Hydra配置有:

代码语言:javascript
复制
  --grant-types authorization_code,refresh_token,client_credentials,implicit 
  --response-types token,code,id_token 

这应该会给出refresh_tokens。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-22 13:24:19

client_credentials不会颁发刷新令牌。您需要使用authorization_code flow来获取刷新令牌。

https://docs.authlib.org/en/latest/client/oauth2.html#oauth2session-for-authorization-code

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48907773

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档