使用OAuth以编程方式访问Trello

Gol*_*den 4 authentication oauth trello

我目前正在尝试使用Node.js Web应用程序访问私有Trello板.我想要实现的是创建新卡.不幸的是,我陷入了接收令牌的过程中.

我使用node-oath库并按如下方式嵌入它:

var OAuth = require('oauth').OAuth,
    oauth = new OAuth('https://trello.com/1/OAuthGetRequestToken',
                      'https://trello.com/1/OAuthGetAccessToken',
                      myKey,
                      myOAuthSecret,
                      '1.0',
                      undefined,
                      'PLAINTEXT');
Run Code Online (Sandbox Code Playgroud)

之后,我尝试通过调用获取令牌:

oauth.getOAuthRequestToken(function (error, oauth_token, oauth_secret, results) {
  if (error) return console.log('1: ' + JSON.stringify(error));
    oauth.getOAuthAccessToken(oauth_token, oauth_secret, function (error, oauth_access_token, oauth_access_token_secret, access_results) {
      if (error) return console.log('2: ' + JSON.stringify(error));
      // ...
Run Code Online (Sandbox Code Playgroud)

当我运行此代码时,我总是收到以下错误消息:

1: {"statusCode":500,"data":"Invalid Signature"}
Run Code Online (Sandbox Code Playgroud)

所以,显然第一个OAuth请求有问题.我已经看到Trello也支持HMAC-SHA1.当我使用它而不是PLAINTEXT时,第一个请求成功,但第二个请求失败,因为我没有指定oauth_verifier.

不幸的是,我对如何提供此验证器没有任何想法.我已经阅读了OAuth RFC,但这对我没有帮助.

基本上,我实际上并不需要 HMAC-SHA1,PLAINTEXT会很好.

有谁知道可能出错了什么?

PS:我在Trello开发板上读到,一旦有一个错误不允许Trello访问正文中发送的密钥,所以他们建议你使用查询字符串发送它.但即使我将第一个代码块更改为

var OAuth = require('oauth').OAuth,
    oauth = new OAuth('https://trello.com/1/OAuthGetRequestToken?key=' + myKey,
                      'https://trello.com/1/OAuthGetAccessToken',
                      myKey,
                      myOAuthSecret,
                      '1.0',
                      undefined,
                      'PLAINTEXT');
Run Code Online (Sandbox Code Playgroud)

它根本不会改变任何东西: - /

有任何想法吗?

Bre*_*ett 5

来自npm(下面链接)的node-trello软件包对我来说很好,我没有通过检查发现你的代码有任何问题; 如果我是你,我会做的是安装node-trello并将其用作一个工作示例; 如果这不起作用,那么您可能需要重新生成开发人员密钥.

节点trello:

https://github.com/adunkman/node-trello

https://github.com/adunkman/node-trello/blob/master/lib/trello-oauth.coffee

  • 这真是用户使用Trello授权应用程序的唯一方式; Trello必须能够说'嘿,我们即将允许这个应用程序查看(并可能修改)您帐户中的非公开信息; 这可以吗?' 在安全方面,很难绕过这个要求. (2认同)