Как отправить запрос OAuth в Node

Я хочу получить доступ к WS REST API в файле node.js. у меня естьoauth_consumer_key иoauth_token и конечная точка API. Oauth_signature_method - это HMAC-SHA1.

Как отправить запрос OAuth в Node?

Есть ли модуль / библиотека для генерации заголовков запроса? То, что я ожидаю, это такая функция:

var httprequest = createRequest(url, method, consumer_key, token);
ОБНОВЛЕНИЕ 14.10.2012. Добавление решения.

Я использую код ниже.

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);
});

Ответы на вопрос(2)

Ваш ответ на вопрос