1

我想将 PassportJS 与 Freshbooks.com 一起使用。

Freshbooks 使用 OAuth 1.0a,因此我复制了 passport-linkedin 存储库并尝试将其转换为 Freshbooks。

我收到一个我不明白的错误:

failed to obtain request token (status: 400 data: Unsupported signature method specified.)

Passport 有调试开关吗?我还使用 OAuthStrategy 组合了另一个版本,但我遇到了同样的错误。

Freshbooks OAuth API 在这里:http: //developers.freshbooks.com/authentication-2/#OAuth

要在模块中运行示例服务器:

git clone git@github.com:MichaelJCole/passport-freshbooks.git
npm install
npm install passport express ejs passport-oauth  
node example/login/app.js

堆栈跟踪:

failed to obtain request token (status: 400 data: Unsupported signature method specified.)
    at /home/michaelcole/scm/passport-freshbooks/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:196:36
    at /home/michaelcole/scm/passport-freshbooks/node_modules/passport-oauth/node_modules/oauth/lib/oauth.js:518:17
    at passBackControl (/home/michaelcole/scm/passport-freshbooks/node_modules/passport-oauth/node_modules/oauth/lib/oauth.js:374:13)
    at IncomingMessage.<anonymous> (/home/michaelcole/scm/passport-freshbooks/node_modules/passport-oauth/node_modules/oauth/lib/oauth.js:386:9)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:910:16
    at process._tickCallback (node.js:415:13)
4

1 回答 1

1

好的,这看起来像是因为服务器想要 PLAINTEXT 编码与 HMAC-SHA1

解决方案是更新策略以包含签名方法

function Strategy(options, verify) {
  options = options || {};
  options.requestTokenURL = 'https://' + options.serverName + '/oauth/oauth_request.php';
  options.accessTokenURL = 'https://' + options.serverName + '/oauth/oauth_access.php';
  options.userAuthorizationURL = 'https://' + options.serverName + '/oauth/oauth_authorize.php';
  options.signatureMethod = "PLAINTEXT";  // < ------------------------ HERE
  options.sessionKey = options.sessionKey || 'oauth:freshbooks';

  console.log(options.requestTokenURL);
于 2013-06-26T15:24:58.183 回答