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

编程入门 行业动态 更新时间:2024-10-28 03:33:30
本文介绍了通过授权代码从Lepture / Authlib获取刷新令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I am trying to develop a simple tool that uses Authlib OAuth2 server to get refresh tokens but example server here does not issue a refresh token. When I print the token I get the following:

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

该流程是此处所引用的授权代码;首先,我要处理同意部分:

The flow is Authorization code as referred here; first I handle the consent part:

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 的配置,并在提交中添加:

Add a config of OAUTH2_REFRESH_TOKEN_GENERATOR=True, added in commit:

github/authlib/example-oauth2-server/commit/4f2f48cc3e74b631d9c4365

请参阅文档: docs.authlib/en/latest/flask/oauth2.html#server

更多推荐

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

本文发布于:2023-11-26 15:39:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634294.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:令牌   代码   Lepture   Authlib

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!