刷新 OAuth 刷新令牌标准行为吗?
Is refreshing the OAuth refresh token standard behavior?
我正在为 OAuth API(特别是 TD Ameritrade)实现一个 API 包装器,我遇到了一个有趣的功能。与我见过的大多数 OAuth 实现不同,其中刷新令牌在一段时间内有效,然后用户必须重新验证,这个 API 支持 refreshing the refresh token itself.
特别是,如果您向身份验证端点发送具有以下格式的请求,您将获得一个有效期为 90 天的全新刷新令牌作为奖励:
grant_type: refresh_token
refresh_token: <Refresh Token>
access_type: offline
client_id: <OAuth API Key>
有些事情很奇怪。首先,我以前从未见过此功能。我使用的大多数 API 似乎都不支持这种刷新。其次,我似乎找不到任何直接的方法来使用 authlib 等常见的 OAuth 客户端库实现来实现这一点。这些库通常支持透明访问令牌刷新,但我还没有看到类似透明刷新令牌刷新的东西。最后,我认为在这种情况下使用 refresh_token
授权类型是过载的,因为相同的授权类型用于刷新 access 令牌,而不是刷新令牌。两者之间的唯一区别是 access_type: offline
.
的使用
那么我的问题是:这个标准的 OAuth 行为是在一些我还没有设法挖掘的 RFC 中描述的,还是这个 API 的开发者破解的非标准行为进入其他符合标准的 API?答案将决定我是一次性在自己的库中实现透明刷新,还是尝试向我最喜欢的 OAuth 客户端实现提交补丁。
access_type: offline
参数不是 OAuth 中的标准,但已被使用,例如通过 Google 在他们的令牌端点请求中 - 您必须传递它才能获得刷新令牌。
另一方面,刷新令牌是 OAuth 标准的一部分。 RFC 6749 声明在对令牌端点的响应中:
The authorization server MAY issue a new refresh token, in which case
the client MUST discard the old refresh token and replace it with the
new refresh token. The authorization server MAY revoke the old
refresh token after issuing a new refresh token to the client. If a
new refresh token is issued, the refresh token scope MUST be
identical to that of the refresh token included by the client in the
request.
所以刷新刷新令牌是标准的一部分,但应该与他们的 API 不同。
我正在为 OAuth API(特别是 TD Ameritrade)实现一个 API 包装器,我遇到了一个有趣的功能。与我见过的大多数 OAuth 实现不同,其中刷新令牌在一段时间内有效,然后用户必须重新验证,这个 API 支持 refreshing the refresh token itself.
特别是,如果您向身份验证端点发送具有以下格式的请求,您将获得一个有效期为 90 天的全新刷新令牌作为奖励:
grant_type: refresh_token
refresh_token: <Refresh Token>
access_type: offline
client_id: <OAuth API Key>
有些事情很奇怪。首先,我以前从未见过此功能。我使用的大多数 API 似乎都不支持这种刷新。其次,我似乎找不到任何直接的方法来使用 authlib 等常见的 OAuth 客户端库实现来实现这一点。这些库通常支持透明访问令牌刷新,但我还没有看到类似透明刷新令牌刷新的东西。最后,我认为在这种情况下使用 refresh_token
授权类型是过载的,因为相同的授权类型用于刷新 access 令牌,而不是刷新令牌。两者之间的唯一区别是 access_type: offline
.
那么我的问题是:这个标准的 OAuth 行为是在一些我还没有设法挖掘的 RFC 中描述的,还是这个 API 的开发者破解的非标准行为进入其他符合标准的 API?答案将决定我是一次性在自己的库中实现透明刷新,还是尝试向我最喜欢的 OAuth 客户端实现提交补丁。
access_type: offline
参数不是 OAuth 中的标准,但已被使用,例如通过 Google 在他们的令牌端点请求中 - 您必须传递它才能获得刷新令牌。
另一方面,刷新令牌是 OAuth 标准的一部分。 RFC 6749 声明在对令牌端点的响应中:
The authorization server MAY issue a new refresh token, in which case the client MUST discard the old refresh token and replace it with the new refresh token. The authorization server MAY revoke the old refresh token after issuing a new refresh token to the client. If a new refresh token is issued, the refresh token scope MUST be identical to that of the refresh token included by the client in the request.
所以刷新刷新令牌是标准的一部分,但应该与他们的 API 不同。