use of com.google.api.client.auth.oauth.OAuthHmacSigner in project odysee-android by OdyseeTeam.
the class TwitterRequestTokenTask method doInBackground.
public String doInBackground(Void... params) {
try {
OAuthHmacSigner signer = new OAuthHmacSigner();
signer.clientSharedSecret = new String(Base64.decode(consumerSecret, Base64.NO_WRAP), StandardCharsets.UTF_8.name());
OAuthParameters oauthParams = new OAuthParameters();
oauthParams.callback = "https://lbry.tv";
oauthParams.consumerKey = new String(Base64.decode(consumerKey, Base64.NO_WRAP), StandardCharsets.UTF_8.name());
oauthParams.signatureMethod = "HMAC-SHA-1";
oauthParams.signer = signer;
oauthParams.computeNonce();
oauthParams.computeTimestamp();
oauthParams.computeSignature("POST", new GenericUrl(ENDPOINT));
RequestBody body = RequestBody.create(new byte[0]);
Request request = new Request.Builder().url(ENDPOINT).addHeader("Authorization", oauthParams.getAuthorizationHeader()).post(body).build();
OkHttpClient client = new OkHttpClient.Builder().build();
Response response = client.newCall(request).execute();
return response.body().string();
} catch (Exception ex) {
error = ex;
return null;
}
}
use of com.google.api.client.auth.oauth.OAuthHmacSigner in project che by eclipse.
the class OAuthAuthenticator method getOAuthHmacSigner.
private OAuthHmacSigner getOAuthHmacSigner(@Nullable String clientSecret, @Nullable String oauthTemporaryToken) throws NoSuchAlgorithmException, InvalidKeySpecException {
final OAuthHmacSigner signer = new OAuthHmacSigner();
signer.clientSharedSecret = clientSecret;
signer.tokenSharedSecret = sharedTokenSecrets.remove(oauthTemporaryToken);
return signer;
}
use of com.google.api.client.auth.oauth.OAuthHmacSigner in project data-transfer-project by google.
the class OAuth1Config method getAccessTokenSigner.
/**
* Returns the {@link OAuthSigner} for the access token request
*/
default OAuthSigner getAccessTokenSigner(String clientSecret, String tokenSecret) {
OAuthHmacSigner signer = new OAuthHmacSigner();
signer.clientSharedSecret = clientSecret;
signer.tokenSharedSecret = tokenSecret;
return signer;
}
use of com.google.api.client.auth.oauth.OAuthHmacSigner in project google-oauth-java-client by googleapis.
the class OAuthHmacThreeLeggedFlow method complete.
public Credential complete(String authorizationCode) throws IOException {
Preconditions.checkNotNull(transport, "Must call setHttpTransport before calling complete.");
OAuthGetAccessToken accessToken = new OAuthGetAccessToken(authorizationServerUrl);
accessToken.temporaryToken = tempToken;
accessToken.transport = transport;
OAuthHmacSigner signer = new OAuthHmacSigner();
signer.clientSharedSecret = consumerSecret;
signer.tokenSharedSecret = tempTokenSecret;
accessToken.signer = signer;
accessToken.consumerKey = consumerKey;
accessToken.verifier = authorizationCode;
OAuthCredentialsResponse credentials = accessToken.execute();
signer.tokenSharedSecret = credentials.tokenSecret;
OAuthHmacCredential accessCredential = new OAuthHmacCredential(userId, consumerKey, consumerSecret, credentials.tokenSecret, credentials.token);
return accessCredential;
}
use of com.google.api.client.auth.oauth.OAuthHmacSigner in project data-transfer-project by google.
the class OAuth1Config method getRequestTokenSigner.
/**
* Returns the {@link OAuthSigner} for the initial token request
*/
default OAuthSigner getRequestTokenSigner(String clientSecret) {
OAuthHmacSigner signer = new OAuthHmacSigner();
signer.clientSharedSecret = clientSecret;
return signer;
}
Aggregations