use of org.springframework.social.oauth2.OAuth2Template in project syndesis by syndesisio.
the class TestCredentialProviderFactory method create.
@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;
}
use of org.springframework.social.oauth2.OAuth2Template in project syndesis by syndesisio.
the class SalesforceCredentialProviderFactory method createConnectionFactory.
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;
}
Aggregations