org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeAccessTokenProvider Java Examples
The following examples show how to use
org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeAccessTokenProvider.
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: DefaultUserInfoRestTemplateFactory.java From spring-security-oauth2-boot with Apache License 2.0 | 6 votes |
@Override public OAuth2RestTemplate getUserInfoRestTemplate() { if (this.oauth2RestTemplate == null) { this.oauth2RestTemplate = createOAuth2RestTemplate( this.details == null ? DEFAULT_RESOURCE_DETAILS : this.details); this.oauth2RestTemplate.getInterceptors().add(new AcceptJsonRequestInterceptor()); AuthorizationCodeAccessTokenProvider accessTokenProvider = new AuthorizationCodeAccessTokenProvider(); accessTokenProvider.setTokenRequestEnhancer(new AcceptJsonRequestEnhancer()); this.oauth2RestTemplate.setAccessTokenProvider(accessTokenProvider); if (!CollectionUtils.isEmpty(this.customizers)) { AnnotationAwareOrderComparator.sort(this.customizers); for (UserInfoRestTemplateCustomizer customizer : this.customizers) { customizer.customize(this.oauth2RestTemplate); } } } return this.oauth2RestTemplate; }
Example #2
Source File: OAuth2Util.java From DAFramework with MIT License | 6 votes |
public static Filter wechat(AuthorizationCodeResourceDetails client, ResourceServerProperties resourceServerProperties, String path, OAuth2ClientContext oauth2ClientContext) { OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationFilter = new OAuth2ClientAuthenticationProcessingFilter(path); OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(client, oauth2ClientContext); AuthorizationCodeAccessTokenProvider accessTokenProvider = new AuthorizationCodeAccessTokenProvider(); accessTokenProvider.setAuthorizationRequestEnhancer((request, resource, form, headers) -> { form.set("appid", resource.getClientId()); form.set("secret", resource.getClientSecret()); form.set("scope", "snsapi_userinfo"); form.set("response_type", "code"); form.set("#wechat_redirect", ""); }); accessTokenProvider.setMessageConverters(converters()); oAuth2RestTemplate.setAccessTokenProvider(accessTokenProvider); oAuth2RestTemplate.setRetryBadAccessTokens(true); oAuth2ClientAuthenticationFilter.setRestTemplate(oAuth2RestTemplate); UserInfoTokenServices tokenServices = new UserInfoTokenServices(resourceServerProperties.getUserInfoUri(), client.getClientId()); tokenServices.setRestTemplate(oAuth2RestTemplate); oAuth2ClientAuthenticationFilter.setTokenServices(tokenServices); return oAuth2ClientAuthenticationFilter; }
Example #3
Source File: FacebookConfiguration.java From OAuth-2.0-Cookbook with MIT License | 5 votes |
@Bean public OAuth2RestTemplate restTemplate(OAuth2ClientContext context) { OAuth2RestTemplate rest = new OAuth2RestTemplate(resourceDetails(), context); rest.setAccessTokenProvider( new AccessTokenProviderChain( Arrays.asList(new AuthorizationCodeAccessTokenProvider()))); return rest; }
Example #4
Source File: GoogleConfiguration.java From OAuth-2.0-Cookbook with MIT License | 5 votes |
@Bean public OAuth2RestTemplate restTemplate(OAuth2ClientContext context) { OAuth2RestTemplate rest = new OAuth2RestTemplate(resourceDetails(), context); AccessTokenProviderChain providerChain = new AccessTokenProviderChain( Arrays.asList(new AuthorizationCodeAccessTokenProvider())); rest.setAccessTokenProvider(providerChain); return rest; }
Example #5
Source File: GoogleConfiguration.java From OAuth-2.0-Cookbook with MIT License | 5 votes |
@Bean public OAuth2RestTemplate restTemplate(OAuth2ClientContext context) { OAuth2RestTemplate rest = new OAuth2RestTemplate(resourceDetails(), context); AccessTokenProviderChain providerChain = new AccessTokenProviderChain( Arrays.asList(new AuthorizationCodeAccessTokenProvider())); rest.setAccessTokenProvider(providerChain); return rest; }
Example #6
Source File: RunkeeperShim.java From shimmer with Apache License 2.0 | 5 votes |
@Override public AuthorizationCodeAccessTokenProvider getAuthorizationCodeAccessTokenProvider() { AuthorizationCodeAccessTokenProvider provider = new AuthorizationCodeAccessTokenProvider(); provider.setTokenRequestEnhancer(new RunkeeperTokenRequestEnhancer()); return provider; }
Example #7
Source File: ClientConfiguration.java From OAuth-2.0-Cookbook with MIT License | 4 votes |
@Bean public OAuth2RestTemplate oauth2RestTemplate() { OAuth2ProtectedResourceDetails resourceDetails = authorizationCode(); OAuth2RestTemplate template = new OAuth2RestTemplate(resourceDetails, oauth2ClientContext); AccessTokenProviderChain provider = new AccessTokenProviderChain( Arrays.asList(new AuthorizationCodeAccessTokenProvider())); provider.setClientTokenServices(clientTokenServices); template.setAccessTokenProvider(provider); return template; }
Example #8
Source File: ClientConfiguration.java From OAuth-2.0-Cookbook with MIT License | 4 votes |
@Bean public OAuth2RestTemplate oauth2RestTemplate() { OAuth2ProtectedResourceDetails resourceDetails = authorizationCode(); OAuth2RestTemplate template = new OAuth2RestTemplate(resourceDetails, oauth2ClientContext); AccessTokenProviderChain provider = new AccessTokenProviderChain( Arrays.asList(new AuthorizationCodeAccessTokenProvider())); provider.setClientTokenServices(clientTokenServices); template.setAccessTokenProvider(provider); return template; }
Example #9
Source File: AuthorizationCodeGrantTests.java From spring-boot-demo with MIT License | 4 votes |
@Test void testAttemptedTokenAcquisitionWithNoRedirect() { AuthorizationCodeAccessTokenProvider provider = new AuthorizationCodeAccessTokenProvider(); assertThrows(UserRedirectRequiredException.class, () -> provider.obtainAccessToken(resource, new DefaultAccessTokenRequest())); }
Example #10
Source File: FitbitShim.java From shimmer with Apache License 2.0 | 4 votes |
@Override public AuthorizationCodeAccessTokenProvider getAuthorizationCodeAccessTokenProvider() { return fitbitAuthorizationCodeAccessTokenProvider; }
Example #11
Source File: IHealthShim.java From shimmer with Apache License 2.0 | 4 votes |
@Override public AuthorizationCodeAccessTokenProvider getAuthorizationCodeAccessTokenProvider() { return new IHealthAuthorizationCodeAccessTokenProvider(); }
Example #12
Source File: JawboneShim.java From shimmer with Apache License 2.0 | 4 votes |
public AuthorizationCodeAccessTokenProvider getAuthorizationCodeAccessTokenProvider() { return new JawboneAuthorizationCodeAccessTokenProvider(); }
Example #13
Source File: MisfitShim.java From shimmer with Apache License 2.0 | 4 votes |
@Override public AuthorizationCodeAccessTokenProvider getAuthorizationCodeAccessTokenProvider() { return new MisfitAuthorizationCodeAccessTokenProvider(); }
Example #14
Source File: MovesShim.java From shimmer with Apache License 2.0 | 4 votes |
public AuthorizationCodeAccessTokenProvider getAuthorizationCodeAccessTokenProvider() { AuthorizationCodeAccessTokenProvider provider = new AuthorizationCodeAccessTokenProvider(); provider.setTokenRequestEnhancer(new MovesAccessTokenRequestEnhancer()); return provider; }
Example #15
Source File: GoogleFitShim.java From shimmer with Apache License 2.0 | 2 votes |
public AuthorizationCodeAccessTokenProvider getAuthorizationCodeAccessTokenProvider() { return new GoogleAuthorizationCodeAccessTokenProvider(); }
Example #16
Source File: OAuth2Shim.java From shimmer with Apache License 2.0 | votes |
protected abstract AuthorizationCodeAccessTokenProvider getAuthorizationCodeAccessTokenProvider();