OAuth authorization issue 401 when trying from node.js

I tried to use the OAuth for yahoo search. I am new to this concept.

I registered in yahoo and got consumer and secret key.

I implemented it using JavaScript, when i test my code (test.js) using node.js(i installed npm install oauth –g) i got the following error instead of XML.

{ [Error: getaddrinfo ENOTFOUND] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo' }


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

var key = 'dj0yJmk9cU5GT2p5T0VRc3R2JmQ9WVdrOVZHeFZaR1YwTjJFbWNHbzlNQS0tJnM9Y29uc3VtZXJzZWNyZXQmeD1lYg--';
var secret = 'e766c8cbd1c7b31612b1787e1f39b7b27a88433d';

var webSearchUrl = '<https://ysp.yahooapis.com/ysp/web>';
var finalUrl = webSearchUrl + '?q=iphone';
var oa = new OAuth(webSearchUrl, webSearchUrl, key, secret, "1.0", null, "HMAC-SHA1", null, {"Accept-Language": null, "Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "User-Agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0", "Cookie" : ""});
oa.setClientOptions({ requestTokenHttpMethod: 'GET' });

oa.get(finalUrl, '','', function (error, data, resp) {

    if (error || resp.statusCode !== 200) { // if there is a error, exit with error message
        return console.log(error);

    // otherwise, echo incoming data

Please help me in this to get the XML data for processing. Thanks in advance for any help. I am new to this.

0 Replies

Recent Posts

in OAuth General Discussion YDN SDKs