0

I am currently working on connecting the withings api via web and have been able to automate getting token secret and getting the userId from the callback function inside auth, however when trying to implement step 3 (generating token) I always get signing error. Here is the base logic please help if possible.

  nonce = getNonce(32);
  date = Math.round((new Date()).getTime() / 1000.0);
      var requestSig = oauthSign.hmacsign(
        'GET',
        'https://oauth.withings.com/account/access_token',
        {oauth_consumer_key: <myconsumerkey>,
          oauth_nonce: nonce,
          oauth_signature_method: 'HMAC-SHA1',
          oauth_timestamp: date.toString(),
          oauth_token: oauth_token,
          oauth_version: '1.0'
        }, newSecret);
      var hey = encodeURIComponent(requestSig);
      var permanentTokensLink = "https://oauth.withings.com/account/access_token?oauth_consumer_key=<myconsumerkey>&oauth_nonce="+nonce+"&oauth_signature="+hey+"&oauth_signature_method=HMAC-SHA1&oauth_timestamp="+date+"&oauth_token="+oauth_token+"&oauth_version=1.0";
      return {link:permanentTokensLink, newSecret: newSecret, tokensecret: oauth_token_secret, dataObj: dataObj, token: oauth_token};

newSecrect is a consumersercret&tokensecret, and permanentTokensLink is where I should be able to click to to get the access key and secret. Why is this not working?

4

1 回答 1

0

我在签名参数和我正在创建的链接中缺少一个 oauth 验证器,并且秘密应该被分成两部分(消费者秘密、令牌秘密),以便 npm 包 hmacsign 正确使用。

于 2016-08-29T07:52:08.837 回答