问题
So I generate URL same as what we get from withings developer site.
However I get {“status”:342}.
I am using java and using below for oauth nonce, timestamp and oauth signature
But when I replace these 3 values from what I get from withings website, it works just fine. I dont understand what I am doing wrong. Any help is appreciated
- String.valueOf(Math.random()) for nonce
- System.currentTimeMillis() / 1000L – timestamp
SecretKeySpec to generate signature using below
GET
- http://wbsapi.withings.net/measure?action=getmeas&userid=2---0
- oauth_consumer_key=00000000061e0bf7f7b109903040dc------&oauth_nonce=0.4509674797693397&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1414031787&oauth_token=000000-3b5f9e4704d270551e69b45db31de4ec88b4ebe03&oauth_version=1.0
回答1:
One thing to consider in generating URLs is when/where your URL encoding is happening. Some of the great tools like RestSharp encode the string when generated. If you have encoded your oauth_signature and added it as a parameter to your string, it will be encoded again. Eagle eye your final string to be certain that you aren't double encoding your oauth_signature or other generated value. For example, what is a %3D in your encoded oauth_signature will become a %253D in your final string and quickly result in a 342 code.
来源:https://stackoverflow.com/questions/26517181/withings-web-api-call-signature-issue