06-17-2014 02:03
06-17-2014 02:03
Hi, When I generate HMAC SHA1 signature, for base string, generated one from my code is different from Request Token Signature Debug Tool. Thinkings are working with signature generated by Request Token Signature Debug Tool and not with my code generated Signature.
For example:
---------------------------------------------------------------
Base String - POST&https%3A%2F%2Fapi.fitbit.com%2Foauth%2Frequest_token&oauth_consumer_key%3Dbc2ca1c6198046a68622c86d0e3169c8%26oauth_nonce%3D123456%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1402993400%26oauth_version%3D1.0
Signature generated by my code - p4uqLlJnuNaYideTomvccSfvzRY=
Signature generated by Request Token Signature Debug Tool - 4+HGkgj5qztXK0UQGfCA87cFhss=
------------------------------------------------------------------
My java code to generate Signature is following:
----------------------------------------------------------------
public static 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());
return Base64.encodeBase64String(digest);
}
----------------------------------------------------------------
Can anyone tell me what is the bases for generating signature from base string in Request Token Signature Debug tool.
Regards,
Sreeram MC
Answered! Go to the Best Answer.
06-17-2014 06:00
06-17-2014 06:00
Hi there,
I got the issues. I had to append "&" along with the Client (Consumer) Secret. Debugged the code and found out.
Cheers.
06-17-2014 06:00
06-17-2014 06:00
Hi there,
I got the issues. I had to append "&" along with the Client (Consumer) Secret. Debugged the code and found out.
Cheers.