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");
}
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;
}
use of com.github.scribejava.core.model.OAuthConfig in project scribejava by scribejava.
the class OAuth10aService method getRequestToken.
public final OAuth1RequestToken getRequestToken() throws IOException, InterruptedException, ExecutionException {
final OAuthConfig config = getConfig();
config.log("obtaining request token from " + api.getRequestTokenEndpoint());
final OAuthRequest request = prepareRequestTokenRequest();
config.log("sending request...");
final Response response = execute(request);
final String body = response.getBody();
config.log("response status code: " + response.getCode());
config.log("response body: " + body);
return api.getRequestTokenExtractor().extract(response);
}
use of com.github.scribejava.core.model.OAuthConfig in project scribejava by scribejava.
the class OAuth10aService method addOAuthParams.
private void addOAuthParams(OAuthRequest request, String tokenSecret) {
final OAuthConfig config = getConfig();
request.addOAuthParameter(OAuthConstants.TIMESTAMP, api.getTimestampService().getTimestampInSeconds());
request.addOAuthParameter(OAuthConstants.NONCE, api.getTimestampService().getNonce());
request.addOAuthParameter(OAuthConstants.CONSUMER_KEY, config.getApiKey());
request.addOAuthParameter(OAuthConstants.SIGN_METHOD, api.getSignatureService().getSignatureMethod());
request.addOAuthParameter(OAuthConstants.VERSION, getVersion());
final String scope = config.getScope();
if (scope != null) {
request.addOAuthParameter(OAuthConstants.SCOPE, scope);
}
request.addOAuthParameter(OAuthConstants.SIGNATURE, getSignature(request, tokenSecret));
config.log("appended additional OAuth parameters: " + MapUtils.toString(request.getOauthParameters()));
}
use of com.github.scribejava.core.model.OAuthConfig in project scribejava by scribejava.
the class OAuth10aService method signRequest.
@Override
public void signRequest(OAuth1AccessToken token, OAuthRequest request) {
final OAuthConfig config = getConfig();
config.log("signing request: " + request.getCompleteUrl());
if (!token.isEmpty() || api.isEmptyOAuthTokenParamIsRequired()) {
request.addOAuthParameter(OAuthConstants.TOKEN, token.getToken());
}
config.log("setting token to: " + token);
addOAuthParams(request, token.getTokenSecret());
appendSignature(request);
}
Aggregations