I've spent most of today try to implement Instapaper's XAuth API. I haven't even been able to get an oauth token, yet.
Any ideas what I'm doing wrong?
I'm using node.js and the oauth module. It's my understanding that I need to pass the username, password, amd mode as extra parameters. And the oauth module should take care of all of the oauth parameters. But it's not. Here's the code:
var OAuth = require('oauth').OAuth;
var oauth = new OAuth(
'',
'https://www.instapaper.com/api/1/oauth/access_token',
'CONSUMER_KEY',
'CONSUMER_SECRET',
'1.0',
null,
'HMAC-SHA1',
null
);
var extra = {
'x_auth_username': 'USERNAME',
'x_auth_password': 'PASSWORD',
'x_auth_mode': 'client_auth'
};
var hello = oauth._prepareParameters('', '', 'POST', 'https://www.instapaper.com/api/1/oauth/access_token', null);
var url = 'https://www.instapaper.com/api/1/oauth/access_token';
var f = true;
for (var i in hello) {
if (f) {
url += '?';
f = false;
} else {
url += '&';
}
url += hello[i][0] + '=' + hello[i][1];
}
console.log(url+'&x_auth_mode=client_auth&x_auth_username=&x_auth_password=')
oauth._performSecureRequest('', '', "POST", url+'&x_auth_mode=client_auth&x_auth_username=&x_auth_password=', null, null, null, function(error, data, response) {
console.log(error, data)
});
And it returns this:
{ statusCode: 401,
data: 'oauth_signature [pWRf4W9k9nogID/O90Ng29bR2K0=] does not match expected value [eqJ8zD1bKeUa3InpDyegGDAbSnM=]' } 'oauth_signature [pWRf4W9k9nogID/O90Ng29bR2K0=] does not match expected value [eqJ8zD1bKeUa3InpDyegGDAbSnM=]'}