com.google.api.client.auth.oauth.OAuthParameters Java Examples

The following examples show how to use com.google.api.client.auth.oauth.OAuthParameters. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OAuthHmacCredential.java    From google-oauth-java-client with Apache License 2.0 5 votes vote down vote up
private void postConstruct() {
  OAuthHmacSigner signer = new OAuthHmacSigner();
  signer.clientSharedSecret = sharedSecret;
  signer.tokenSharedSecret = tokenSharedSecret;

  authorizer = new OAuthParameters();
  authorizer.consumerKey = consumerKey;
  authorizer.signer = signer;
  authorizer.token = token;
}
 
Example #2
Source File: OAuthHmacCredential.java    From android-oauth-client with Apache License 2.0 5 votes vote down vote up
private void postConstruct() {
    OAuthHmacSigner signer = new OAuthHmacSigner();
    signer.clientSharedSecret = sharedSecret;
    signer.tokenSharedSecret = tokenSharedSecret;

    authorizer = new OAuthParameters();
    authorizer.consumerKey = consumerKey;
    authorizer.signer = signer;
    authorizer.token = getAccessToken();
}
 
Example #3
Source File: OAuthSigner.java    From Woocommerce-Android-Client with MIT License 4 votes vote down vote up
public LinkedHashMap<String, String> getSignature(Map<String, String> options, RequestMethod requestMethod, String endpoint) {
    LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();

    OAuthParameters parameters = new OAuthParameters();
    parameters.computeTimestamp();
    parameters.computeNonce();
    parameters.version = "1.0";
    parameters.consumerKey = wooCommerce.getWc_key();
    GenericUrl genericUrl = new GenericUrl();
    genericUrl.setScheme(wooCommerce.isHttps() ? "https" : "http");
    genericUrl.setHost(wooCommerce.getBaseUrl());
    genericUrl.appendRawPath("/wc-api");
    genericUrl.appendRawPath("/v3");
    /*
     *    The endpoint to be called is specified next
     *    */

    genericUrl.appendRawPath(endpoint);

    for (Map.Entry<String, String> entry : options.entrySet())
    {
        System.out.println(entry.getKey() + "/" + entry.getValue());
        genericUrl.appendRawPath("/"+entry.getValue());
    }

    OAuthHmacSigner oAuthHmacSigner = new OAuthHmacSigner();
    oAuthHmacSigner.clientSharedSecret = wooCommerce.getWc_secret();


    parameters.signer = oAuthHmacSigner;
    parameters.signatureMethod = wooCommerce.getSigning_method().getVal();
    try {
        parameters.computeSignature(requestMethod.getVal(), genericUrl);
    } catch (GeneralSecurityException e) {
        e.printStackTrace();
    }

    map.put("oauth_consumer_key", parameters.consumerKey);
    map.put("oauth_signature_method", parameters.signatureMethod);
    map.put("oauth_timestamp", parameters.timestamp);
    map.put("oauth_nonce", parameters.nonce);
    map.put("oauth_version", parameters.version);
    map.put("oauth_signature", parameters.signature);

    genericUrl.put("oauth_consumer_key", parameters.consumerKey);
    genericUrl.put("oauth_signature_method", parameters.signatureMethod);
    genericUrl.put("oauth_timestamp", parameters.timestamp);
    genericUrl.put("oauth_nonce", parameters.nonce);
    genericUrl.put("oauth_version", parameters.version);
    genericUrl.put("oauth_signature", parameters.signature);

    Log.i(TAG,genericUrl.build());


    return map;
}