简体   繁体   中英

How do I sign access token request withings oauth 1.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?

我在签名参数中以及正在创建的链接内缺少一个oauth验证程序,并且该机密应该分为两部分(消费者秘密,令牌秘密),以供npm软件包hmacsign正确使用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM