Node.js 如何在节点中发送OAuth请求

Node.js 如何在节点中发送OAuth请求,node.js,oauth,module,Node.js,Oauth,Module,我想访问node.js中的WS-REST API。我有oauth\u消费者密钥和oauth\u令牌以及API端点。oauth_签名_方法是HMAC-SHA1 如何在节点中发送OAuth请求 是否有生成请求头的模块/库?我所期望的是这样一个函数: var httprequest = createRequest(url, method, consumer_key, token); 2012年10月14日更新。添加解决方案 我正在使用下面的代码 var OAuth = require('oau

我想访问node.js中的WS-REST API。我有
oauth\u消费者密钥
oauth\u令牌
以及API端点。oauth_签名_方法是HMAC-SHA1

如何在节点中发送OAuth请求

是否有生成请求头的模块/库?我所期望的是这样一个函数:

var httprequest = createRequest(url, method, consumer_key, token);

  • 2012年10月14日更新。添加解决方案
我正在使用下面的代码

var OAuth = require('oauth').OAuth;

consumer = new OAuth('http://term.ie/oauth/example/request_token.php',
                    'http://term.ie/oauth/example/access_token.php',
                    'key', 'secret', '1.0',
                    null, 'HMAC-SHA1');

// Get the request token                    
consumer.getOAuthRequestToken(function(err, oauth_token, oauth_token_secret, results ){
    console.log('==>Get the request token');
    console.log(arguments);
});


// Get the authorized access_token with the un-authorized one.
consumer.getOAuthAccessToken('requestkey', 'requestsecret', function (err, oauth_token, oauth_token_secret, results){
    console.log('==>Get the access token');
    console.log(arguments);
});

// Access the protected resource with access token
var url='http://term.ie/oauth/example/echo_api.php?method=foo&bar=baz';
consumer.get(url,'accesskey', 'accesssecret', function (err, data, response){
    console.log('==>Access the protected resource with access token');
    console.log(err);
    console.log(data);
});

我们使用的是

这是一个更完整的节点twitter包,看起来更精简、更有用。

这个npm模块肯定需要更多的文档,或者至少需要一些关于每件物品的注释/评论。我知道OAuth是一个标准,但是不同的提供商需要/期望不同的东西,这取决于提供商是谁以及您想要访问什么服务。他与这些例子的联系也消失了。对于那些不知道在OAuth中应该做什么的人来说,这是非常令人沮丧和失望的。没有token_请求是无用的,因为token_请求要么不存在,要么没有文档记录