PassportJS + Freshbooks - OAuth错误

时间:2013-06-25 21:28:01

标签: oauth passport.js

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

Freshbooks使用OAuth 1.0a,所以我复制了passport-linkedin repo并尝试将其转换为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)

1 个答案:

答案 0 :(得分:1)

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

解决方案是更新策略以包含signatureMethod

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);