Search in sources :

Example 1 with OAuthHmacSigner

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;
    }
}
Also used : Response(okhttp3.Response) OkHttpClient(okhttp3.OkHttpClient) OAuthHmacSigner(com.google.api.client.auth.oauth.OAuthHmacSigner) OAuthParameters(com.google.api.client.auth.oauth.OAuthParameters) Request(okhttp3.Request) GenericUrl(com.google.api.client.http.GenericUrl) RequestBody(okhttp3.RequestBody)

Example 2 with OAuthHmacSigner

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;
}
Also used : OAuthHmacSigner(com.google.api.client.auth.oauth.OAuthHmacSigner)

Example 3 with OAuthHmacSigner

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;
}
Also used : OAuthHmacSigner(com.google.api.client.auth.oauth.OAuthHmacSigner)

Example 4 with OAuthHmacSigner

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;
}
Also used : OAuthGetAccessToken(com.google.api.client.auth.oauth.OAuthGetAccessToken) OAuthHmacSigner(com.google.api.client.auth.oauth.OAuthHmacSigner) OAuthCredentialsResponse(com.google.api.client.auth.oauth.OAuthCredentialsResponse)

Example 5 with OAuthHmacSigner

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;
}
Also used : OAuthHmacSigner(com.google.api.client.auth.oauth.OAuthHmacSigner)

Aggregations

OAuthHmacSigner (com.google.api.client.auth.oauth.OAuthHmacSigner)8 OAuthParameters (com.google.api.client.auth.oauth.OAuthParameters)2 OAuthCredentialsResponse (com.google.api.client.auth.oauth.OAuthCredentialsResponse)1 OAuthGetAccessToken (com.google.api.client.auth.oauth.OAuthGetAccessToken)1 GenericUrl (com.google.api.client.http.GenericUrl)1 OkHttpClient (okhttp3.OkHttpClient)1 Request (okhttp3.Request)1 RequestBody (okhttp3.RequestBody)1 Response (okhttp3.Response)1