使用lepture / authlib获取refresh_token

时间:2018-02-21 13:58:20

标签: python oauth-2.0 openid-connect authlib

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

{'access_token': 'the-token', 'expires_in': 3599, 'scope': '', 'token_type': 'bearer', 'expires_at': 1519224804}

打印出来

  --grant-types authorization_code,refresh_token,client_credentials,implicit 
  --response-types token,code,id_token 

从文档中,我看到有一个函数从refresh_token获取访问令牌,但是找不到首先获取refresh_token的方法。如何获得refresh_token? Hydra配置为:

 Glide.with(this).load("url").listener(object : RequestListener<Drawable> {
        override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {


          return true
        }

        override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
            callmethod(resource)     //pass drawable to your method and set the drawable for marker there
            imageSource=resource
            return true
        }

    })

应该分发refresh_tokens。

1 个答案:

答案 0 :(得分:0)

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

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