org.springframework.social.oauth2.OAuth2Template Java Examples

The following examples show how to use org.springframework.social.oauth2.OAuth2Template. 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: CustomFacebookServiceProvider.java    From OAuth-2.0-Cookbook with MIT License 5 votes vote down vote up
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;
}
 
Example #2
Source File: TestCredentialProviderFactory.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@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, Collections.emptyMap());

    final OAuth2Operations operations = spy(new OAuth2Template("testClientId", "testClientSecret",
        "https://test/oauth2/authorize", "https://test/oauth2/token"));
    doReturn(new AccessGrant("token")).when(operations).exchangeForAccess(ArgumentMatchers.anyString(),
        ArgumentMatchers.anyString(), ArgumentMatchers.isNull());

    when(connectionFactory.getOAuthOperations()).thenReturn(operations);

    return credentialProvider;
}
 
Example #3
Source File: SalesforceCredentialProviderFactory.java    From syndesis with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #4
Source File: WechatServiceProvider.java    From spring-social-wechat with Apache License 2.0 4 votes vote down vote up
private static OAuth2Template getOAuth2Template(String appId, String appSecret, String authorizeUrl) {
	OAuth2Template oauth2Template = new WechatOAuth2Template(appId, appSecret, authorizeUrl,
			UrlConstants.ACCESS_TOKEN_API_URL);
	oauth2Template.setUseParametersForClientAuthentication(true);
	return oauth2Template;
}
 
Example #5
Source File: GooglePlusFactory.java    From google-plus-java-api with Apache License 2.0 4 votes vote down vote up
private static OAuth2Template createOAuthTemplate(String clientId, String clientSecret) {
    OAuth2Template template = new OAuth2Template(clientId, clientSecret, AUTH_URL, TOKEN_URL);
    template.setUseParametersForClientAuthentication(true);
    return template;
}