LinkedIn API Fails - Node.js Request

I am trying to make REST API calls to Node.js using request module. I have obtained accessToken and accessTokenSecret.

When I make an api call to obtain my profile I get a result, but when I make an api call to do a company search I get the following error

<error>
  <status>401</status>
  <timestamp>1345187981287</timestamp>
  <request-id>HE45IXV7YZ</request-id>
  <error-code>0</error-code>
  <message>[unauthorized]. OAU:xxxxx|xxxxx|*01|*01:1345188248:kCNFNUu6JePTEy7k5e8Ca9vHAzg=</message>
</error>  

But when I make the same API call using JAVA (Scribe jar), using the same accessToken and accessTokenSecret I get results for the company search.

I am posting my node.js code below for reference

//oauth test

var request = require('request');

var key = 'xxxxx';
var secret = 'xxxxx';
var redirect = '';
var restURL = 'http://api.linkedin.com/v1/company-search?keywords=philips&format=json';
var accessToken = 'xxxxx';
var accessTokenSecret = 'xxxxx';



var proxySetting  = "http://proxy:port/";



function getRequestToken()
{
    var requestOAuth = 
    {
            consumer_key: key
          , consumer_secret: secret
          //, token: accessToken
          //, token_secret: accessTokenSecret
    };

    var requestTokenURL = 'https://api.linkedin.com/uas/oauth/requestToken';
    request.get({'proxy':proxySetting,url:requestTokenURL,oauth:requestOAuth},function(e,r,data)
    {
        console.log('Error is: ' + e);
        console.log('Data is: ' + data);
        console.log('Response is: ' + r);
    });
}




 function getAccessToken()
{
    var accessOAuth = 
    {
            consumer_key: key
          , consumer_secret: secret
          , token: 'xxxxx'
          , token_secret: 'xxxx'
          ,verifier : #####
    };

    var accessTokenURL = 'https://api.linkedin.com/uas/oauth/accessToken';
    request.get({'proxy':proxySetting,url:accessTokenURL,oauth:accessOAuth},function(e,r,data)
    {
        console.log('Error is: ' + e);
        console.log('Data is: ' + data);
        console.log('Response is: ' + r);
    });
}

/         

function comSearch()
{
    var apiToken = 'xxxxx';
    var apiTokenSecret = 'xxxxx';
    var apiOAuth = 
    {
            consumer_key: key
          , consumer_secret: secret
          , token: apiToken
          , token_secret: apiTokenSecret
    };

    var apiURL = 'http://api.linkedin.com/v1/company-search?keywords=philips';
    var peopleProfile = 'http://api.linkedin.com/v1/people/~';
    request.get({'proxy':proxySetting,url:apiURL,oauth:apiOAuth},function(e,r,data)
    {
        console.log('Error is: ' + e);
        console.log('Data is: ' + data);
        console.log('Response is: ' + r);
    });
}                                                             

comSearch();

Following is my header

Response is: GET http://api.linkedin.com/v1/company-search?keywords=philips HTTP/1.1
host: api.linkedin.com
Authorization: OAuth keywords="philips",oauth_consumer_key="xxx",oauth_nonce="xxx",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1345189928",oauth_token="xxx",oauth_version="1.0",oauth_signature="xxx"
content-length: 0
Connection: keep-alive

Could there be some error due to the signature issues ?

I have posted this Issue, but posting it here to reach a wider audience


EDIT 1

Reason why I am using the request module is, it helps me do oauth behind a proxy.

I would love to try out Passport.js or node-oauth or linked-in but none seem to have options where I can specify my proxy

I managed to get it work using node-oauth

Apparently there was code fix provided so that we could access node-oauth over the proxy and that works perfectly fine.

The fix for using node-oauth over a http-proxy was mentioned by Jared Hanson in this SO Question. This fix for node-oauth over a http-proxy can be found here

Please, share your generated base signature string. It seems like your query params were not corectly added to the signature string. In some old post on linkedIn forum I've seen that params need to be organized in the string to sign in alphanumeric order.