Python 使用lepture/authlib获取刷新\u令牌
我正在使用Authlib,并试图从Hydra服务器获取刷新令牌。我有以下代码:Python 使用lepture/authlib获取刷新\u令牌,python,oauth-2.0,openid-connect,authlib,Python,Oauth 2.0,Openid Connect,Authlib,我正在使用Authlib,并试图从Hydra服务器获取刷新令牌。我有以下代码: 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_
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)
这是打印出来的
{'access_token': 'the-token', 'expires_in': 3599, 'scope': '', 'token_type': 'bearer', 'expires_at': 1519224804}
从文档中,我看到有一个从刷新令牌获取访问令牌的函数,但首先找不到获取刷新令牌的方法。我如何获得刷新令牌?Hydra配置有:
--grant-types authorization_code,refresh_token,client_credentials,implicit
--response-types token,code,id_token
应该分发刷新令牌
客户端\u凭据
不会发出刷新令牌。您需要使用授权代码流来获取刷新令牌
我实际上尝试了链接中提到的授权代码流,但我仍然只收到一个访问令牌(即没有刷新令牌)。也许我需要在服务器端设置一些东西吗?@fturkmen