This is my base line:
String args ="oauth_consumer_key="+enc(consumerkey) + "&oauth_nonce="+enc(generateNonce()) + "&oauth_signature_method=HMAC-SHA1" + "&oauth_timestamp="+ timestamp + "&oauth_token="+enc(Home.consToken) + "&oauth_verifier="+verifier+"&oauth_version=1.0"; String base ="POST&"+enc("https://api.linkedin.com/uas/oauth /accessToken") +"&"+ enc(args); String signature =computeHmac(base,consumer_secret+"&"+secretToken);
This is my headline:
String header = "OAuth " + "oauth_consumer_key=\""+ enc(consumerkey)+ "\"," + "oauth_nonce=\""+ enc(generateNonce()) + "\"," + "oauth_signature_method=\"HMAC-SHA1\"," + "oauth_timestamp=\""+ timestamp + "\"," + "oauth_token=\""+Home.consToken + "\"," + "oauth_signature=\""+enc(signature)+"\","+ "oauth_verifier=\""+verifier +"\","+ "oauth_version=\""+1.0+"\"" ;
I use the following method to generate a signature:
public String computeHmac(String baseString, String key) throws NoSuchAlgorithmException, InvalidKeyException, IllegalStateException, UnsupportedEncodingException { Mac mac = Mac.getInstance("HmacSHA1"); SecretKeySpec secret = new SecretKeySpec(key.getBytes(), mac.getAlgorithm()); mac.init(secret); byte[] digest = mac.doFinal(baseString.getBytes()); byte[] result=Base64.encodeBase64(digest); return new String(result); }
while executing this code, I get the following error ...
oauth_problem=signature_invalid& oauth_problem_advice=com.linkedin.security.auth.pub.LoginDeniedInvalidAuthTokenException
can someone help me with this?
Thanks...
android linkedin
Taruni
source share