本文整理匯總了Java中org.springframework.security.oauth2.client.OAuth2RestTemplate.setAccessTokenProvider方法的典型用法代碼示例。如果您正苦於以下問題:Java OAuth2RestTemplate.setAccessTokenProvider方法的具體用法?Java OAuth2RestTemplate.setAccessTokenProvider怎麽用?Java OAuth2RestTemplate.setAccessTokenProvider使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.security.oauth2.client.OAuth2RestTemplate
的用法示例。
在下文中一共展示了OAuth2RestTemplate.setAccessTokenProvider方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: restTemplate
import org.springframework.security.oauth2.client.OAuth2RestTemplate; //導入方法依賴的package包/類
@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;
}
示例2: wechat
import org.springframework.security.oauth2.client.OAuth2RestTemplate; //導入方法依賴的package包/類
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;
}
示例3: restTemplate
import org.springframework.security.oauth2.client.OAuth2RestTemplate; //導入方法依賴的package包/類
@Bean
public OAuth2RestTemplate restTemplate(OAuth2ClientContext context) {
OAuth2RestTemplate rest = new OAuth2RestTemplate(resourceDetails(), context);
rest.setAccessTokenProvider(
new AccessTokenProviderChain(
Arrays.asList(new AuthorizationCodeAccessTokenProvider())));
return rest;
}
示例4: getUserInfoRestTemplateCustomizer
import org.springframework.security.oauth2.client.OAuth2RestTemplate; //導入方法依賴的package包/類
@Bean
public UserInfoRestTemplateCustomizer getUserInfoRestTemplateCustomizer() {
return new UserInfoRestTemplateCustomizer() {
@Override
public void customize(OAuth2RestTemplate template) {
template.setAccessTokenProvider(new MyAuthorizationCodeAccessTokenProvider());
}
};
}
示例5: oauth2RestTemplate
import org.springframework.security.oauth2.client.OAuth2RestTemplate; //導入方法依賴的package包/類
@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;
}
示例6: oauth2RestTemplate
import org.springframework.security.oauth2.client.OAuth2RestTemplate; //導入方法依賴的package包/類
@Bean
public OAuth2RestTemplate oauth2RestTemplate() {
OAuth2ProtectedResourceDetails resourceDetails = passwordResourceDetails();
OAuth2RestTemplate template = new OAuth2RestTemplate(resourceDetails,
oauth2ClientContext);
AccessTokenProviderChain provider = new AccessTokenProviderChain(
Arrays.asList(new ClientCredentialsAccessTokenProvider()));
provider.setClientTokenServices(clientTokenServices);
template.setAccessTokenProvider(provider);
return template;
}
示例7: oauth2RestTemplate
import org.springframework.security.oauth2.client.OAuth2RestTemplate; //導入方法依賴的package包/類
@Bean
public OAuth2RestTemplate oauth2RestTemplate() {
OAuth2ProtectedResourceDetails resourceDetails = passwordResourceDetails();
OAuth2RestTemplate template = new OAuth2RestTemplate(resourceDetails,
oauth2ClientContext);
AccessTokenProviderChain provider = new AccessTokenProviderChain(
Arrays.asList(new ResourceOwnerPasswordAccessTokenProvider()));
provider.setClientTokenServices(clientTokenServices);
template.setAccessTokenProvider(provider);
return template;
}
示例8: oauth2RestTemplate
import org.springframework.security.oauth2.client.OAuth2RestTemplate; //導入方法依賴的package包/類
@Bean
public OAuth2RestTemplate oauth2RestTemplate() {
OAuth2ProtectedResourceDetails resourceDetails = implicitResourceDetails();
OAuth2RestTemplate template = new OAuth2RestTemplate(resourceDetails,
oauth2ClientContext);
AccessTokenProviderChain provider = new AccessTokenProviderChain(
Arrays.asList(new CustomImplicitAccessTokenProvider()));
provider.setClientTokenServices(clientTokenServices);
template.setAccessTokenProvider(provider);
return template;
}