Search in sources :

Example 1 with DefaultApi20

use of com.github.scribejava.core.builder.api.DefaultApi20 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)

Aggregations

DefaultApi20 (com.github.scribejava.core.builder.api.DefaultApi20)1 OAuthConfig (com.github.scribejava.core.model.OAuthConfig)1 OAuthRequest (com.github.scribejava.core.model.OAuthRequest)1