【问题标题】:Refresh token not present in response响应中不存在刷新令牌
【发布时间】:2018-04-22 16:30:20
【问题描述】:

我正在尝试配置 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 一起使用

【问题讨论】:

    标签: spring jwt spring-oauth2


    【解决方案1】:

    这很可能是因为 Spring OAuth 2.0 遵循 OAuth 2.0 规范,该规范在第 4.3.3 节中说:https://www.rfc-editor.org/rfc/rfc6749#section-4.4.3 用于客户端凭据授予类型:

    ... 不应包含刷新令牌。 ...

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-08
    • 2018-02-24
    • 1970-01-01
    • 2021-08-20
    • 2023-03-24
    • 1970-01-01
    • 2021-10-07
    相关资源
    最近更新 更多