Search in sources :

Example 1 with OAuthConfig

use of com.github.scribejava.core.model.OAuthConfig in project scribejava by scribejava.

the class ImgurOAuthServiceImpl method createAccessTokenRequest.

@Override
protected OAuthRequest createAccessTokenRequest(String oauthVerifier) {
    final DefaultApi20 api = getApi();
    final OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
    final OAuthConfig config = getConfig();
    request.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
    request.addBodyParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
    if (ImgurApi.isOob(config)) {
        request.addBodyParameter(OAuthConstants.GRANT_TYPE, "pin");
        request.addBodyParameter("pin", oauthVerifier);
    } else {
        request.addBodyParameter(OAuthConstants.GRANT_TYPE, OAuthConstants.AUTHORIZATION_CODE);
        request.addBodyParameter(OAuthConstants.CODE, oauthVerifier);
    }
    return request;
}
Also used : OAuthRequest(com.github.scribejava.core.model.OAuthRequest) DefaultApi20(com.github.scribejava.core.builder.api.DefaultApi20) OAuthConfig(com.github.scribejava.core.model.OAuthConfig)

Example 2 with OAuthConfig

use of com.github.scribejava.core.model.OAuthConfig in project scribejava by scribejava.

the class OAuth10aService method prepareRequestTokenRequest.

protected OAuthRequest prepareRequestTokenRequest() {
    final OAuthRequest request = new OAuthRequest(api.getRequestTokenVerb(), api.getRequestTokenEndpoint());
    final OAuthConfig config = getConfig();
    config.log("setting oauth_callback to " + config.getCallback());
    request.addOAuthParameter(OAuthConstants.CALLBACK, config.getCallback());
    addOAuthParams(request, "");
    appendSignature(request);
    return request;
}
Also used : OAuthRequest(com.github.scribejava.core.model.OAuthRequest) OAuthConfig(com.github.scribejava.core.model.OAuthConfig)

Example 3 with OAuthConfig

use of com.github.scribejava.core.model.OAuthConfig in project scribejava by scribejava.

the class OAuth10aService method prepareAccessTokenRequest.

protected OAuthRequest prepareAccessTokenRequest(OAuth1RequestToken requestToken, String oauthVerifier) {
    final OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
    final OAuthConfig config = getConfig();
    request.addOAuthParameter(OAuthConstants.TOKEN, requestToken.getToken());
    request.addOAuthParameter(OAuthConstants.VERIFIER, oauthVerifier);
    config.log("setting token to: " + requestToken + " and verifier to: " + oauthVerifier);
    addOAuthParams(request, requestToken.getTokenSecret());
    appendSignature(request);
    return request;
}
Also used : OAuthRequest(com.github.scribejava.core.model.OAuthRequest) OAuthConfig(com.github.scribejava.core.model.OAuthConfig)

Example 4 with OAuthConfig

use of com.github.scribejava.core.model.OAuthConfig in project scribejava by scribejava.

the class ServiceBuilderTest method shouldAcceptValidCallbackUrl.

@Test
public void shouldAcceptValidCallbackUrl() {
    builder.apiKey("key").apiSecret("secret").callback("http://example.com").build(api);
    final OAuthConfig config = api.getConfig();
    assertEquals(config.getApiKey(), "key");
    assertEquals(config.getApiSecret(), "secret");
    assertEquals(config.getCallback(), "http://example.com");
}
Also used : OAuthConfig(com.github.scribejava.core.model.OAuthConfig) Test(org.junit.Test)

Example 5 with OAuthConfig

use of com.github.scribejava.core.model.OAuthConfig in project alf.io by alfio-event.

the class StripeManager method getConnectURL.

public ConnectURL getConnectURL(Function<ConfigurationKeys, Configuration.ConfigurationPathKey> keyResolver) {
    String secret = configurationManager.getRequiredValue(keyResolver.apply(STRIPE_SECRET_KEY));
    String clientId = configurationManager.getRequiredValue(keyResolver.apply(STRIPE_CONNECT_CLIENT_ID));
    String callbackURL = configurationManager.getStringConfigValue(keyResolver.apply(STRIPE_CONNECT_CALLBACK), configurationManager.getRequiredValue(keyResolver.apply(BASE_URL)) + CONNECT_REDIRECT_PATH);
    String state = UUID.randomUUID().toString();
    String code = UUID.randomUUID().toString();
    OAuthConfig config = new OAuthConfig(clientId, secret, callbackURL, "read_write", null, state, "code", null, null, null);
    return new ConnectURL(new StripeConnectApi().getAuthorizationUrl(config, Collections.emptyMap()), state, code);
}
Also used : OAuthConfig(com.github.scribejava.core.model.OAuthConfig)

Aggregations

OAuthConfig (com.github.scribejava.core.model.OAuthConfig)25 OAuthRequest (com.github.scribejava.core.model.OAuthRequest)13 DefaultApi20 (com.github.scribejava.core.builder.api.DefaultApi20)4 Test (org.junit.Test)4 Response (com.github.scribejava.core.model.Response)3 IOException (java.io.IOException)2 OAuth1SignatureType (com.github.scribejava.core.builder.api.OAuth1SignatureType)1 HttpClient (com.github.scribejava.core.httpclient.HttpClient)1 OAuth1AccessToken (com.github.scribejava.core.model.OAuth1AccessToken)1 OAuth1RequestToken (com.github.scribejava.core.model.OAuth1RequestToken)1 OAuth20Service (com.github.scribejava.core.oauth.OAuth20Service)1 Map (java.util.Map)1 OkHttpClient (okhttp3.OkHttpClient)1 Before (org.junit.Before)1