當前位置: 首頁>>代碼示例>>Java>>正文


Java OAuth2RestTemplate.setAccessTokenProvider方法代碼示例

本文整理匯總了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;
}
 
開發者ID:PacktPublishing,項目名稱:OAuth-2.0-Cookbook,代碼行數:9,代碼來源:GoogleConfiguration.java

示例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;
}
 
開發者ID:DataAgg,項目名稱:DAFramework,代碼行數:24,代碼來源:OAuth2Util.java

示例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;
}
 
開發者ID:PacktPublishing,項目名稱:OAuth-2.0-Cookbook,代碼行數:9,代碼來源:FacebookConfiguration.java

示例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());
        }
    };
}
 
開發者ID:yuhuachang,項目名稱:spring-boot-oauth2-azuread,代碼行數:10,代碼來源:WebSecurityConfig.java

示例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;
}
 
開發者ID:PacktPublishing,項目名稱:OAuth-2.0-Cookbook,代碼行數:17,代碼來源:ClientConfiguration.java

示例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;
}
 
開發者ID:PacktPublishing,項目名稱:OAuth-2.0-Cookbook,代碼行數:17,代碼來源:ClientConfiguration.java

示例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;
}
 
開發者ID:PacktPublishing,項目名稱:OAuth-2.0-Cookbook,代碼行數:17,代碼來源:ClientConfiguration.java

示例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;
}
 
開發者ID:PacktPublishing,項目名稱:OAuth-2.0-Cookbook,代碼行數:17,代碼來源:ClientConfiguration.java


注:本文中的org.springframework.security.oauth2.client.OAuth2RestTemplate.setAccessTokenProvider方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。