use of com.github.scribejava.core.model.OAuthConfig in project scribejava by scribejava.
the class OAuth10aService method signRequest.
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);
}
use of com.github.scribejava.core.model.OAuthConfig 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.OAuthConfig 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;
}
use of com.github.scribejava.core.model.OAuthConfig in project scribejava by scribejava.
the class OAuth20Service method createRefreshTokenRequest.
protected OAuthRequest createRefreshTokenRequest(String refreshToken) {
if (refreshToken == null || refreshToken.isEmpty()) {
throw new IllegalArgumentException("The refreshToken cannot be null or empty");
}
final OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getRefreshTokenEndpoint());
final OAuthConfig config = getConfig();
api.getClientAuthenticationType().addClientAuthentication(request, config);
final String scope = config.getScope();
if (scope != null) {
request.addParameter(OAuthConstants.SCOPE, scope);
}
request.addParameter(OAuthConstants.REFRESH_TOKEN, refreshToken);
request.addParameter(OAuthConstants.GRANT_TYPE, OAuthConstants.REFRESH_TOKEN);
return request;
}
use of com.github.scribejava.core.model.OAuthConfig in project scribejava by scribejava.
the class ServiceBuilderTest method shouldReturnConfigDefaultValues.
@Test
public void shouldReturnConfigDefaultValues() {
builder.apiKey("key").apiSecret("secret").build(api);
final OAuthConfig config = api.getConfig();
assertEquals(config.getApiKey(), "key");
assertEquals(config.getApiSecret(), "secret");
assertEquals(config.getCallback(), null);
}
Aggregations