2013-06-25 31 views
1

我想在Freshbooks.com上使用PassportJS。PassportJS + Freshbooks - OAuth错误

Freshbooks使用OAuth 1.0a,所以我复制passport-linkedin回购并试图将其转换为Freshbooks。

我得到一个错误,我不明白:

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

是否有护照调试开关?我还使用OAuthStrategy将另一个版本放在一起,我也遇到了同样的错误。

的Freshbooks OAuth的API是在这里:

git clone [email protected]: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

好吧,这看起来像它发生http://developers.freshbooks.com/authentication-2/#OAuth

要在模块中运行示例服务器因为服务器想要PLAINTEXT编码vs 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);