Search in sources :

Example 1 with DefaultOAuth2RequestAuthenticator

use of org.springframework.security.oauth2.client.DefaultOAuth2RequestAuthenticator in project spring-cloud-framework by zhuwj921.

the class OAuth2RestTemplateConfiguration method oauth2RestTemplate.

@Bean
public OAuth2RestTemplate oauth2RestTemplate() {
    ClientCredentialsResourceDetails resourceDetails = new ClientCredentialsResourceDetails();
    resourceDetails.setClientId("webapp");
    resourceDetails.setClientSecret("webapp");
    resourceDetails.setId("service-user");
    resourceDetails.setAccessTokenUri("http://127.0.0.1:9020/oauth/token");
    OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(resourceDetails);
    oAuth2RestTemplate.setAuthenticator(new DefaultOAuth2RequestAuthenticator());
    return oAuth2RestTemplate;
}
Also used : DefaultOAuth2RequestAuthenticator(org.springframework.security.oauth2.client.DefaultOAuth2RequestAuthenticator) ClientCredentialsResourceDetails(org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails) OAuth2RestTemplate(org.springframework.security.oauth2.client.OAuth2RestTemplate) Bean(org.springframework.context.annotation.Bean)

Aggregations

Bean (org.springframework.context.annotation.Bean)1 DefaultOAuth2RequestAuthenticator (org.springframework.security.oauth2.client.DefaultOAuth2RequestAuthenticator)1 OAuth2RestTemplate (org.springframework.security.oauth2.client.OAuth2RestTemplate)1 ClientCredentialsResourceDetails (org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails)1