use of com.github.scribejava.core.model.OAuthRequest in project scribejava by scribejava.
the class OAuth10aService method getAccessToken.
public 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 OAuth10aService method getRequestToken.
public 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 OAuth20Service method createAccessTokenRequest.
protected OAuthRequest createAccessTokenRequest(String code) {
final OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
final OAuthConfig config = getConfig();
api.getClientAuthenticationType().addClientAuthentication(request, config);
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 createRevokeTokenRequest.
protected OAuthRequest createRevokeTokenRequest(String tokenToRevoke, TokenTypeHint tokenTypeHint) {
final OAuthRequest request = new OAuthRequest(Verb.POST, api.getRevokeTokenEndpoint());
api.getClientAuthenticationType().addClientAuthentication(request, getConfig());
request.addParameter("token", tokenToRevoke);
if (tokenTypeHint != null) {
request.addParameter("token_type_hint", tokenTypeHint.toString());
}
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);
api.getClientAuthenticationType().addClientAuthentication(request, config);
return request;
}
Aggregations