node.js의 WS REST API에 액세스하고 싶습니다. 나는 oauth_consumer_key
과 oauth_token
그리고 API 종점을 가지고 있습니다. oauth_signature_method는 HMAC-SHA1이다.노드에서 OAuth 요청을 보내는 방법
노드에서 OAuth 요청을 보내는 방법은 무엇입니까?
요청 헤더를 생성 할 모듈/라이브러리가 있습니까?
var httprequest = createRequest(url, method, consumer_key, token);
- UPDATE 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);
});
이 npm 모듈은 각 문서가 무엇인지에 대해 더 많은 문서 또는 최소한 몇 가지 메모/의견을 분명히 필요로합니다. 나는 OAuth가 표준이지만, 다른 공급자는 공급자가 누구이고 어떤 서비스에 액세스 할 것인지에 따라 다른 것을 요구하거나 기대한다고 알고 있습니다. 그의 모범과의 연관성 또한 사라졌습니다. OAuth에서 무엇을 해야할지 정확히 모르는 사람이라면 매우 실망스럽고 실망 스럽습니다. – user137717