org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest Java Examples
The following examples show how to use
org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SecurityConfig.java From messaging-app with Apache License 2.0 | 5 votes |
private OAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> authorizationCodeTokenResponseClient() { OAuth2AccessTokenResponseHttpMessageConverter tokenResponseHttpMessageConverter = new OAuth2AccessTokenResponseHttpMessageConverter(); tokenResponseHttpMessageConverter.setTokenResponseConverter(new CustomAccessTokenResponseConverter()); RestTemplate restTemplate = new RestTemplate(Arrays.asList( new FormHttpMessageConverter(), tokenResponseHttpMessageConverter)); restTemplate.setErrorHandler(new OAuth2ErrorResponseErrorHandler()); DefaultAuthorizationCodeTokenResponseClient tokenResponseClient = new DefaultAuthorizationCodeTokenResponseClient(); tokenResponseClient.setRestOperations(restTemplate); return tokenResponseClient; }
Example #2
Source File: DemoApplicationTests.java From keycloak-springsecurity5-sample with GNU General Public License v3.0 | 5 votes |
private OAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> mockAccessTokenResponseClient() { OAuth2AccessTokenResponse accessTokenResponse = OAuth2AccessTokenResponse.withToken("access-token-1234") .tokenType(OAuth2AccessToken.TokenType.BEARER) .expiresIn(60 * 1000) .build(); OAuth2AccessTokenResponseClient tokenResponseClient = mock(OAuth2AccessTokenResponseClient.class); when(tokenResponseClient.getTokenResponse(any())).thenReturn(accessTokenResponse); return tokenResponseClient; }
Example #3
Source File: CustomRequestEntityConverter.java From tutorials with MIT License | 5 votes |
@Override public RequestEntity<?> convert(OAuth2AuthorizationCodeGrantRequest req) { RequestEntity<?> entity = defaultConverter.convert(req); MultiValueMap<String, String> params = (MultiValueMap<String,String>) entity.getBody(); params.add("test2", "extra2"); System.out.println(params.entrySet()); return new RequestEntity<>(params, entity.getHeaders(), entity.getMethod(), entity.getUrl()); }