Search in sources :

Example 1 with OAuthRequest

use of com.github.scribejava.core.model.OAuthRequest 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 OAuthRequest

use of com.github.scribejava.core.model.OAuthRequest 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 OAuthRequest

use of com.github.scribejava.core.model.OAuthRequest 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 OAuthRequest

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

the class ObjectMother method createSampleOAuthRequest.

public static OAuthRequest createSampleOAuthRequest() {
    final OAuthRequest request = new OAuthRequest(Verb.GET, "http://example.com");
    request.addOAuthParameter(OAuthConstants.TIMESTAMP, "123456");
    request.addOAuthParameter(OAuthConstants.CONSUMER_KEY, "AS#$^*@&");
    request.addOAuthParameter(OAuthConstants.CALLBACK, "http://example/callback");
    request.addOAuthParameter(OAuthConstants.SIGNATURE, "OAuth-Signature");
    return request;
}
Also used : OAuthRequest(com.github.scribejava.core.model.OAuthRequest)

Example 5 with OAuthRequest

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

the class ObjectMother method createSampleOAuthRequestPort80.

public static OAuthRequest createSampleOAuthRequestPort80() {
    final OAuthRequest request = new OAuthRequest(Verb.GET, "http://example.com:80");
    request.addOAuthParameter(OAuthConstants.TIMESTAMP, "123456");
    request.addOAuthParameter(OAuthConstants.CONSUMER_KEY, "AS#$^*@&");
    request.addOAuthParameter(OAuthConstants.CALLBACK, "http://example/callback");
    request.addOAuthParameter(OAuthConstants.SIGNATURE, "OAuth-Signature");
    return request;
}
Also used : OAuthRequest(com.github.scribejava.core.model.OAuthRequest)

Aggregations

OAuthRequest (com.github.scribejava.core.model.OAuthRequest)107 Response (com.github.scribejava.core.model.Response)85 ServiceBuilder (com.github.scribejava.core.builder.ServiceBuilder)62 Scanner (java.util.Scanner)60 OAuth2AccessToken (com.github.scribejava.core.model.OAuth2AccessToken)48 OAuth20Service (com.github.scribejava.core.oauth.OAuth20Service)45 OAuth1AccessToken (com.github.scribejava.core.model.OAuth1AccessToken)21 OAuth1RequestToken (com.github.scribejava.core.model.OAuth1RequestToken)21 OAuth10aService (com.github.scribejava.core.oauth.OAuth10aService)20 Random (java.util.Random)16 OAuthConfig (com.github.scribejava.core.model.OAuthConfig)13 Test (org.junit.Test)11 HttpUrl (okhttp3.HttpUrl)9 MockResponse (okhttp3.mockwebserver.MockResponse)8 MockWebServer (okhttp3.mockwebserver.MockWebServer)8 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)6 DefaultApi20 (com.github.scribejava.core.builder.api.DefaultApi20)4 ExecutionException (java.util.concurrent.ExecutionException)4