本文整理汇总了Java中org.springframework.social.oauth2.OAuth2Template类的典型用法代码示例。如果您正苦于以下问题:Java OAuth2Template类的具体用法?Java OAuth2Template怎么用?Java OAuth2Template使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OAuth2Template类属于org.springframework.social.oauth2包,在下文中一共展示了OAuth2Template类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOAuth2Template
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
private static OAuth2Template getOAuth2Template(String appId,
String appSecret, String apiVersion) {
String graphApiURL = "https://graph.facebook.com/v" + apiVersion + "/";
OAuth2Template template = new OAuth2Template(appId, appSecret,
"https://www.facebook.com/v" + apiVersion + "/dialog/oauth",
graphApiURL + "oauth/access_token");
template.setUseParametersForClientAuthentication(true);
return template;
}
示例2: create
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
@Override
public CredentialProvider create(final SocialProperties properties) {
@SuppressWarnings("unchecked")
final OAuth2ConnectionFactory<Object> connectionFactory = mock(OAuth2ConnectionFactory.class);
when(connectionFactory.generateState()).thenReturn("test-state");
properties.setAppId("appId");
properties.setAppSecret("appSecret");
final OAuth2Applicator applicator = new OAuth2Applicator(properties);
applicator.setAccessTokenProperty("accessToken");
applicator.setClientIdProperty("clientId");
applicator.setClientSecretProperty("clientSecret");
applicator.setRefreshTokenProperty("refreshToken");
final CredentialProvider credentialProvider = new OAuth2CredentialProvider<>("test-provider", connectionFactory,
applicator);
@SuppressWarnings({ "unchecked", "rawtypes" })
final Class<MultiValueMap<String, String>> additionalParametersType = (Class) MultiValueMap.class;
final OAuth2Operations operations = spy(new OAuth2Template("testClientId", "testClientSecret",
"https://test/oauth2/authorize", "https://test/oauth2/token"));
doReturn(new AccessGrant("token")).when(operations).exchangeForAccess(Matchers.anyString(),
Matchers.anyString(), Matchers.any(additionalParametersType));
when(connectionFactory.getOAuthOperations()).thenReturn(operations);
return credentialProvider;
}
示例3: createConnectionFactory
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
static SalesforceConnectionFactory
createConnectionFactory(final SocialProperties salesforceProperties) {
final SalesforceConnectionFactory salesforce = new SalesforceConnectionFactory(salesforceProperties.getAppId(),
salesforceProperties.getAppSecret());
final OAuth2Template oAuthOperations = (OAuth2Template) salesforce.getOAuthOperations();
// Salesforce requires OAuth client id and secret on the OAuth request
oAuthOperations.setUseParametersForClientAuthentication(true);
return salesforce;
}
示例4: getOAuth2Template
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
private static OAuth2Template getOAuth2Template(String appId, String appSecret)
{
OAuth2Template oauth2Template = new WechatOAuth2Template(appId, appSecret,
"https://open.weixin.qq.com/connect/oauth2/authorize", "https://api.weixin.qq.com/cgi-bin/token");
oauth2Template.setUseParametersForClientAuthentication(true);
return oauth2Template;
}
示例5: create
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
@Override
public CredentialProvider create(final SocialProperties properties) {
@SuppressWarnings("unchecked")
final OAuth2ConnectionFactory<Object> connectionFactory = mock(OAuth2ConnectionFactory.class);
when(connectionFactory.generateState()).thenReturn("test-state");
properties.setAppId("appId");
properties.setAppSecret("appSecret");
final OAuth2Applicator applicator = new OAuth2Applicator(properties);
applicator.setAccessTokenProperty("accessToken");
applicator.setClientIdProperty("clientId");
applicator.setClientSecretProperty("clientSecret");
applicator.setRefreshTokenProperty("refreshToken");
final CredentialProvider credentialProvider = new OAuth2CredentialProvider<>("test-provider", connectionFactory,
applicator);
final OAuth2Operations operations = spy(new OAuth2Template("testClientId", "testClientSecret",
"https://test/oauth2/authorize", "https://test/oauth2/token"));
doReturn(new AccessGrant("token")).when(operations).exchangeForAccess(Matchers.anyString(),
Matchers.anyString(), Matchers.any(MultiValueMap.class));
when(connectionFactory.getOAuthOperations()).thenReturn(operations);
return credentialProvider;
}
示例6: GitlabServiceProvider
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
public GitlabServiceProvider(GitlabConfiguration configuration) {
super(new OAuth2Template(
configuration.getApplicationId(),
configuration.getApplicationSecret(),
configuration.getAuthorizeUrl(),
configuration.getAccessTokenUrl()
));
this.configuration = configuration;
}
示例7: getOAuth2Template
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
private static OAuth2Template getOAuth2Template(String appId, String appSecret) {
OAuth2Template oAuth2Template = new OAuth2Template(appId, appSecret,
KeyRockTemplate.API_BASE_URL + "/oauth2/authorize",
KeyRockTemplate.API_BASE_URL + "/oauth2/token");
//False to send clientId and clientSecret in "Authentication" header rather than POST body when exchanging the code
oAuth2Template.setUseParametersForClientAuthentication(false);
return oAuth2Template;
}
示例8: exchangeCredentialsForClientToken
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
private static String exchangeCredentialsForClientToken(String consumerKey, String consumerSecret) {
OAuth2Template oauth2 = new OAuth2Template(consumerKey, consumerSecret, "",
"https://api.twitter.com/oauth2/token");
return oauth2.authenticateClient().getAccessToken();
}
示例9: createOAuth2Template
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
private static OAuth2Template createOAuth2Template(String clientId, String clientSecret) {
OAuth2Template oAuth2Template = new OAuth2Template(clientId, clientSecret, "https://discordapp.com/api/oauth2/authorize", "https://discordapp.com/api/oauth2/token");
oAuth2Template.setUseParametersForClientAuthentication(true);
return oAuth2Template;
}
示例10: getOauth2Operations
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
private static OAuth2Template getOauth2Operations(String clientId, String clientSecret, String accessTokenUrl) {
OAuth2Template template = new OAuth2Template(clientId, clientSecret, "", accessTokenUrl);
template.setUseParametersForClientAuthentication(true);
return template;
}
示例11: createOAuth2Template
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
private static OAuth2Template createOAuth2Template(String clientId, String clientSecret) {
OAuth2Template oAuth2Template = new OAuth2Template(clientId, clientSecret, "https://www.strava.com/oauth/authorize", "https://www.strava.com/oauth/token");
oAuth2Template.setUseParametersForClientAuthentication(true);
return oAuth2Template;
}
示例12: getOAuth2Template
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
private static OAuth2Template getOAuth2Template(String clientId, String clientSecret) {
OAuth2Template oAuth2Template = new WeiboOAuth2Template(clientId, clientSecret, "https://api.weibo.com/oauth2/authorize",
"https://api.weibo.com/oauth2/access_token");
oAuth2Template.setUseParametersForClientAuthentication(true);
return oAuth2Template;
}
示例13: createOAuth2Template
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
private static OAuth2Template createOAuth2Template(String domain, String clientId, String clientSecret) {
OAuth2Template oAuth2Template = new OAuth2Template(clientId, clientSecret, "https://" + domain + ".auth0.com/authorize", "https://" + domain + ".auth0.com/oauth/token");
oAuth2Template.setUseParametersForClientAuthentication(true);
return oAuth2Template;
}
示例14: BattlenetServiceProvider
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
public BattlenetServiceProvider(String clientId, String clientSecret) {
super(new OAuth2Template(clientId, clientSecret,
// TODO eu -> settings
"https://eu.battle.net/oauth/authorize",
"https://eu.battle.net/oauth/token"));
}
示例15: oauth2Template
import org.springframework.social.oauth2.OAuth2Template; //导入依赖的package包/类
@Bean
public OAuth2Operations oauth2Template(Environment env) {
return new OAuth2Template(env.getProperty("clientId"), env.getProperty("clientSecret"), "", "https://api.twitter.com/oauth2/token");
}