use of org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails in project tutorials by eugenp.
the class CustomConfigAuthorizationServerIntegrationTest method givenOAuth2Context_whenAccessTokenIsRequestedByClientWithWriteScope_ThenAccessTokenIsNotNull.
@Test
public void givenOAuth2Context_whenAccessTokenIsRequestedByClientWithWriteScope_ThenAccessTokenIsNotNull() {
ClientCredentialsResourceDetails resourceDetails = getClientCredentialsResourceDetails("baeldung-admin", singletonList("write"));
OAuth2RestTemplate restTemplate = getOAuth2RestTemplate(resourceDetails);
OAuth2AccessToken accessToken = restTemplate.getAccessToken();
assertNotNull(accessToken);
}
use of org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails in project tutorials by eugenp.
the class CustomConfigAuthorizationServerIntegrationTest method givenOAuth2Context_whenAccessTokenIsRequested_ThenAccessTokenValueIsNotNull.
@Test
public void givenOAuth2Context_whenAccessTokenIsRequested_ThenAccessTokenValueIsNotNull() {
ClientCredentialsResourceDetails resourceDetails = getClientCredentialsResourceDetails("baeldung", singletonList("read"));
OAuth2RestTemplate restTemplate = getOAuth2RestTemplate(resourceDetails);
OAuth2AccessToken accessToken = restTemplate.getAccessToken();
assertNotNull(accessToken);
}
use of org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails in project tutorials by eugenp.
the class OAuth2IntegrationTestSupport method getOAuth2RestTemplate.
protected OAuth2RestTemplate getOAuth2RestTemplate(final ClientCredentialsResourceDetails resourceDetails) {
DefaultOAuth2ClientContext clientContext = new DefaultOAuth2ClientContext();
OAuth2RestTemplate restTemplate = new OAuth2RestTemplate(resourceDetails, clientContext);
restTemplate.setMessageConverters(singletonList(new MappingJackson2HttpMessageConverter()));
return restTemplate;
}
Aggregations