Reputation: 16227
I'd like to use PassportJS with Freshbooks.com.
Freshbooks uses OAuth 1.0a, so I copied over the passport-linkedin repo and attempted to convert it to Freshbooks.
I'm getting an error I don't understand:
failed to obtain request token (status: 400 data: Unsupported signature method specified.)
Is there a debug switch for Passport? I also put together another version using just the OAuthStrategy and I'm getting the same error.
The Freshbooks OAuth API is here: http://developers.freshbooks.com/authentication-2/#OAuth
To run the example server in the module:
git clone [email protected]:MichaelJCole/passport-freshbooks.git
npm install
npm install passport express ejs passport-oauth
node example/login/app.js
The stack trace:
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)
Upvotes: 1
Views: 372
Reputation: 16227
Ok, this looks like it happened because the server wanted PLAINTEXT encoding vs HMAC-SHA1
The solution was to update the strategy to include 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);
Upvotes: 1