Why does the JdbcClientTokenServices not save refresh tokens?

207 views Asked by At

I have a Spring application that acts as an OAuth2 client. I implemented a JdbcClientTokenServices to persist the tokens for each user that succesfully authenticates.

@Bean
public OAuth2RestTemplate restTemplate(OAuth2ClientContext clientContext) {
    OAuth2RestTemplate template = new OAuth2RestTemplate(resource(), clientContext);
    AccessTokenProviderChain accessTokenProvider = new AccessTokenProviderChain(
            Collections.<AccessTokenProvider>singletonList(
                    new AuthorizationCodeAccessTokenProvider()
            ));
    accessTokenProvider.setClientTokenServices(clientTokenServices());
    accessTokenProvider.supportsRefresh(resource());
    template.setAccessTokenProvider(accessTokenProvider);
    return template;
}

@Bean
public JdbcClientTokenServices clientTokenServices() {
    return new JdbcClientTokenServices(dataSource);
}

This code makes use of a oauth_client_token table. When I looked for the content in this table, I noticed it only saves the access token? I was wondering why the refresh token does not get saved aswell since the refresh token should be longer lived than the access token anyway.

0

There are 0 answers