Authentication KeyClope不会刷新令牌

Authentication KeyClope不会刷新令牌,authentication,oauth-2.0,jwt,keycloak,Authentication,Oauth 2.0,Jwt,Keycloak,我正在尝试刷新令牌,但KeyClope返回400错误请求错误,并显示以下消息: { "error": "invalid_grant", "error_description": "Invalid refresh token" } 我在如下请求中成功获取刷新令牌: curl --location --request POST 'http://localhost:8080/auth/realms/my_

我正在尝试刷新令牌,但KeyClope返回
400错误请求
错误,并显示以下消息:

{
    "error": "invalid_grant",
    "error_description": "Invalid refresh token"
}
我在如下请求中成功获取刷新令牌:

curl --location --request POST 'http://localhost:8080/auth/realms/my_realm/protocol/openid-connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=my_user' \
--data-urlencode 'password=my_password' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'client_id=my_client_id' \
--data-urlencode 'client_secret=my_client_secret'
curl --location --request POST 'http://localhost:8080/auth/realms/my_realm/protocol/openid-connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=my_client_id' \
--data-urlencode 'grant_type=refresh_token' \
--data-urlencode 'refresh_token=my_refresh_token' \
--data-urlencode 'client_secret=my_client_secret'
所以我得到了一个带有访问令牌和刷新令牌的JWT响应。当我加载它们时,它们似乎都是有效的

但是当我尝试使用刷新令牌时,我得到了上一个错误。请求如下:

curl --location --request POST 'http://localhost:8080/auth/realms/my_realm/protocol/openid-connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=my_user' \
--data-urlencode 'password=my_password' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'client_id=my_client_id' \
--data-urlencode 'client_secret=my_client_secret'
curl --location --request POST 'http://localhost:8080/auth/realms/my_realm/protocol/openid-connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=my_client_id' \
--data-urlencode 'grant_type=refresh_token' \
--data-urlencode 'refresh_token=my_refresh_token' \
--data-urlencode 'client_secret=my_client_secret'
在Key斗篷的日志中,没有任何问题的线索

原因是什么?或者至少,有没有办法从KeyClope的响应或日志中获取有关错误原因的更多信息

编辑:

我已经实现了一个用户存储提供程序SPI,因此它可以对外部DB进行身份验证,但它不会将用户管理到KeyClope中。是否需要令牌所有者用户存在于keydove中,以便刷新令牌工作


谢谢。

最后,这是我的用户存储提供商SPI中的一个问题。有必要实现以下方法,因为KeyClope从刷新令牌获取用户ID,并通过该ID查找用户:

public UserModel getUserById(String id, RealmModel realm) {
    StorageId storageId = new StorageId(id);
    String username = storageId.getExternalId();
    return getUserByUsername(username, realm);
}