温馨提示:本文翻译自stackoverflow.com,查看原文请点击:oauth 2.0 - Server Get a refresh token with an access token using WSO2 Identity Server
oauth-2.0 wso2 wso2is

oauth 2.0 - 服务器使用WSO2 Identity Server获取带有访问令牌的刷新令牌

发布于 2020-04-21 17:04:12

我正在进行以下curl调用:

curl -k -d "grant_type=client_credentials" -H "Authorization: Basic <Encoded ID & Secret>)" https://MyIDPUrl/token

我得到以下回应:

{
    "access_token":"MyAccessTokenHere",
    "scope":"am_application_scope default",
    "token_type":"Bearer",
    "expires_in":3212
}

一切似乎都很好,除了我没有得到刷新令牌。我尝试添加&scope=openid到url,并在响应中添加了id_token,但未添加刷新令牌。

如何使用WSO2获得刷新令牌?

查看更多

提问者
Vaccano
被浏览
47
Hasanthi 2020-02-07 12:11

是的,对于client_credentials授予类型,没有使用刷新令牌的用法。但是,如果您要获取刷新令牌,则可以通过更改identity.xml(IS_Home / repository / conf / identity)中的配置来允许获取刷新令牌。在以下部分中,

        <SupportedGrantType>
            <GrantTypeName>client_credentials</GrantTypeName>
            <GrantTypeHandlerImplClass>org.wso2.carbon.identity.oauth2.token.handlers.grant.ClientCredentialsGrantHandler</GrantTypeHandlerImplClass>
            <IsRefreshTokenAllowed>false</IsRefreshTokenAllowed>
            <IdTokenAllowed>false</IdTokenAllowed>
        </SupportedGrantType>

如果将IsRefreshTokenAllowed的值更改为true,则应返回刷新令牌。(更改配置值后,需要重新启动服务器)。默认情况下为false,因为在此授予类型中没有用户参与刷新令牌是没有用的。