是否可以拥有多个具有相同客户端凭据的有效访问令牌? [英] Is it possible to have multiple valid access tokens with the same client credentials?
问题描述
我有一个设置了 OAuth2 身份验证的 API.客户使用 WSO2 订阅了我的 API.我们不使用刷新令牌.所有访问令牌都会在 1 小时后过期.
I have an API set with OAuth2 authentication. A client has subscribe to my API using WSO2. We don't use refresh tokens. All access tokens expire in 1 hour.
如果我的客户端请求 2 个具有相同客户端凭据的访问令牌会怎样?第一个令牌会被撤销,还是两个令牌都可以存活 1 小时?
What happens if my client requests 2 access tokens with the same client credentials? Will the first token be revoked or will both tokens live 1 hour?
推荐答案
当您使用客户端凭据请求令牌时,它将提供一个有效期为 1 小时的访问令牌.如果您在该 1 小时内再次从令牌 API 请求令牌,那么它将提供相同的令牌.基本上,如果有一个有效的令牌,那么它将返回它.这是默认行为.
When you request a token with client credentials, it will give an access token which is valid for 1 hour. If you again request a token from the token API within that 1 hour period, then it will give the same token. Basically, if there is a valid token, then it will return that. This is the default behavior.
但如果您使用 API Store 并单击令牌重新生成,那么它将首先撤销令牌并为您获取新的访问令牌.
But if you are using the API Store and click on token re-generation, then it will first revoke the token and get you a new access token.
如果您想同时为同一个客户端凭据获取两个不同的访问令牌,那么您可以使用范围.当令牌请求有不同的作用域时,会返回两个不同的访问令牌.
If you want to get two different access tokens for the same client credentials at the same time, then you can use a scope. When there are different scopes in the token request, it will return two different access tokens.
这篇关于是否可以拥有多个具有相同客户端凭据的有效访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!