【发布时间】:2011-09-22 17:15:01
【问题描述】:
我今天大部分时间都在尝试实现 Instapaper 的 XAuth API。我什至还没有获得 oauth 令牌。
知道我做错了什么吗?
我正在使用 node.js 和 oauth 模块。据我了解,我需要将用户名、密码、amd 模式作为额外参数传递。 oauth 模块应该处理所有的 oauth 参数。但事实并非如此。代码如下:
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)
});
它返回这个:
{ statusCode: 401,
data: 'oauth_signature [pWRf4W9k9nogID/O90Ng29bR2K0=] does not match expected value [eqJ8zD1bKeUa3InpDyegGDAbSnM=]' } 'oauth_signature [pWRf4W9k9nogID/O90Ng29bR2K0=] does not match expected value [eqJ8zD1bKeUa3InpDyegGDAbSnM=]'}
【问题讨论】:
-
我仍然在努力解决这个问题。请帮忙。
-
你有没有得到这个工作?发布一个可行的解决方案,或将解决方案标记为正确答案会很棒
标签: node.js oauth xauth instapaper