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;
}
use of com.github.scribejava.core.model.OAuthRequest 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.OAuthRequest in project scribejava by scribejava.
the class OAuth10aService method getAccessToken.
public final OAuth1AccessToken getAccessToken(OAuth1RequestToken requestToken, String oauthVerifier) throws IOException, InterruptedException, ExecutionException {
getConfig().log("obtaining access token from " + api.getAccessTokenEndpoint());
final OAuthRequest request = prepareAccessTokenRequest(requestToken, oauthVerifier);
final Response response = execute(request);
return api.getAccessTokenExtractor().extract(response);
}
use of com.github.scribejava.core.model.OAuthRequest in project scribejava by scribejava.
the class OAuth20Service method createAccessTokenRequest.
protected OAuthRequest createAccessTokenRequest(String code) {
final OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
final OAuthConfig config = getConfig();
request.addParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
request.addParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
request.addParameter(OAuthConstants.CODE, code);
request.addParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
final String scope = config.getScope();
if (scope != null) {
request.addParameter(OAuthConstants.SCOPE, scope);
}
request.addParameter(OAuthConstants.GRANT_TYPE, OAuthConstants.AUTHORIZATION_CODE);
return request;
}
use of com.github.scribejava.core.model.OAuthRequest in project scribejava by scribejava.
the class OAuth20Service method createAccessTokenPasswordGrantRequest.
protected OAuthRequest createAccessTokenPasswordGrantRequest(String username, String password) {
final OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
final OAuthConfig config = getConfig();
request.addParameter(OAuthConstants.USERNAME, username);
request.addParameter(OAuthConstants.PASSWORD, password);
final String scope = config.getScope();
if (scope != null) {
request.addParameter(OAuthConstants.SCOPE, scope);
}
request.addParameter(OAuthConstants.GRANT_TYPE, OAuthConstants.PASSWORD);
final String apiKey = config.getApiKey();
final String apiSecret = config.getApiSecret();
if (apiKey != null && apiSecret != null) {
request.addHeader(OAuthConstants.HEADER, OAuthConstants.BASIC + ' ' + Base64Encoder.getInstance().encode(String.format("%s:%s", apiKey, apiSecret).getBytes(Charset.forName("UTF-8"))));
}
return request;
}
Aggregations