Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

My standard HMAC SHA1 different from Request Token Signature Debug Tool.

ANSWERED

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

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Hi there,

 

I got the issues. I had to append "&" along with the Client (Consumer) Secret. Debugged the code and found out. 

 

Cheers.

View best answer in original post

Best Answer
0 Votes
1 REPLY 1

Hi there,

 

I got the issues. I had to append "&" along with the Client (Consumer) Secret. Debugged the code and found out. 

 

Cheers.

Best Answer
0 Votes