服务器使用 WSO2 Identity Server 获取带有访问令牌的刷新令牌
Server Get a refresh token with an access token using WSO2 Identity Server
我正在进行以下 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 授权类型不 return 刷新令牌。
这是有道理的,因为刷新令牌的意义在于不打扰用户再次登录。但是使用 client_credentials,您可以去获取另一个访问令牌。
是的,对于 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,它应该 return 刷新令牌。 (修改配置值后需要重启服务器)。默认情况下它是 false,因为没有用户参与此授权类型刷新令牌没有用。
正如@Vaccano 所说,使用 client_credentials
授权类型不会 return 刷新令牌。
您可以改为使用 Password
授权类型,这会 return 刷新令牌:
curl -k -X POST https://localhost:9443/oauth2/token
-d "grant_type=password&username=Username&password=Password"
-H "Authorization: Basic Base64(consumer-key:consumer-secret)"
我正在进行以下 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 授权类型不 return 刷新令牌。
这是有道理的,因为刷新令牌的意义在于不打扰用户再次登录。但是使用 client_credentials,您可以去获取另一个访问令牌。
是的,对于 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,它应该 return 刷新令牌。 (修改配置值后需要重启服务器)。默认情况下它是 false,因为没有用户参与此授权类型刷新令牌没有用。
正如@Vaccano 所说,使用 client_credentials
授权类型不会 return 刷新令牌。
您可以改为使用 Password
授权类型,这会 return 刷新令牌:
curl -k -X POST https://localhost:9443/oauth2/token
-d "grant_type=password&username=Username&password=Password"
-H "Authorization: Basic Base64(consumer-key:consumer-secret)"