简体   繁体   English

我如何使用OAuth 1.0签署访问令牌请求

[英]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. 我目前正在通过Web连接withings api,并且能够自动获取令牌密钥并从auth中的回调函数获取userId,但是当尝试实现步骤3(生成令牌)时,我总是会遇到签名错误。 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. newSecrect是一个consumerercret&tokensecret,而永久令牌链接是我应该能够单击以获取访问密钥和机密的地方。 Why is this not working? 为什么这不起作用?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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