我试图配置spirng oauth2来返回刷新令牌,但下面没有它是我的配置:
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
ClientDetailsServiceBuilder.ClientBuilder cb = clients.inMemory()
.withClient(CRAZY_FRONT_CLIENT_ID)
.secret("yuyuyu")
.authorizedGrantTypes("refresh_token", "client_credentials", "password")
.scopes("read", "write", "trust")
.refreshTokenValiditySeconds(500)
}
@Bean
@Primary
public DefaultTokenServices tokenServices() {
DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
defaultTokenServices.setTokenStore(tokenStore());
defaultTokenServices.setSupportRefreshToken(true);
defaultTokenServices.setRefreshTokenValiditySeconds(TEN_DAYS);
defaultTokenServices.setReuseRefreshToken(true);
defaultTokenServices.setTokenEnhancer(accessTokenConverter());
defaultTokenServices.setAccessTokenValiditySeconds(TEN_DAYS);
return defaultTokenServices;
}
,我得到的回应是:
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJyZWFkIiwid3JpdGUiLCJ0cnVzdCJdLCJleHAiMDU5MTIsImp0aSI6IjY4MDMwOTMyLTgxNzMtNGExMi05OTE0LWExMTYIsImNsaWVudF9pZCI6ImNyYXp5LWZyb250In0.xHjBl_IFENbqGOtjZouJAI_HjHuQyNS3SOOsnJh5LzU",
"token_type": "bearer",
"expires_in": 863999,
"scope": "read write trust",
"jti": "68030932-8173-4a12-9914-a116541e6ea8"
}
请求使用grant_type = client_credentials
答案 0 :(得分:0)
这很可能是因为Spring OAuth 2.0遵循OAuth 2.0规范,该规范在4.3.3节中说明:https://tools.ietf.org/html/rfc6749#section-4.4.3用于客户端凭据授权类型:
......不应包括刷新令牌。 ...