【发布时间】:2021-12-02 16:04:45
【问题描述】:
为什么使用 JWT 刷新令牌。 在https://www.oauth.com/oauth2-servers/access-tokens/refreshing-access-tokens/ 要使用我需要发送的刷新令牌
POST / oauth / HTTP / 1.1 token
Host: authorization-server.com
grant_type = refresh_token
& refresh_token = xxxxxxxxxxx
& client_id = xxxxxxxxxx
& client_secret = xxxxxxxxxx
使用 refresh_token 有什么意义,因为我可以直接请求访问令牌
POST / HTTP token / 1.1
Host: authorization-server.com
grant_type = client_credentials
& client_id = xxxxxxxxxx
& client_secret = xxxxxxxxxx
我要连接的服务需要 client_id 和 client_secret 来刷新令牌。没有这些参数,它返回
{
"error": "invalid_request",
"error_description": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed."
}
附加client_id和client_secret时,返回一个有效的JWT
【问题讨论】:
-
出于安全考虑,访问令牌仅在短时间内有效。刷新令牌用于刷新访问令牌,无需再次登录。有关此主题的更多信息:auth0.com/blog/…auth0.com/docs/security/tokens/refresh-tokens
-
我了解访问令牌和刷新令牌之间的区别。我不明白为什么在刷新令牌请求中需要 client_id 和 client_secret。这意味着我必须从用户那里保存或下载 client_secret。
标签: jwt