我正在进行以下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获得刷新令牌?
是的,对于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,因为在此授予类型中没有用户参与刷新令牌是没有用的。