Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LinkedIN API Calls Fail #299

Closed
celestialcitizen opened this issue Aug 17, 2012 · 4 comments
Closed

LinkedIN API Calls Fail #299

celestialcitizen opened this issue Aug 17, 2012 · 4 comments

Comments

@celestialcitizen
Copy link

Hi

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:5wrjwsf3zdw5|76c1a687-be2a-40fd-812e-2d00122e4e39|*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: '03581aec-4a21-4c25-ad41-0c53f2d4f2f5'
          , token_secret: '2568b111-d7e8-4155-8bd8-05d5202aa940'
          ,verifier : 33115
    };

    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();
@celestialcitizen
Copy link
Author

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="5wrjwsf3zdw5",oauth_nonce="8C6D0076A1834F3D9A3AB38FFA361354",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1345189928",oauth_token="76c1a687-be2a-40fd-812e-2d00122e4e39",oauth_version="1.0",oauth_signature="Sb5ckxzYYLwzItNNq0P6Z6yDK50%3D"
content-length: 0
Connection: keep-alive

Could there be some error due to the signature issues ?

@mikeal
Copy link
Member

mikeal commented Sep 25, 2012

what kind of error do you get when it fails?

@celestialcitizen
Copy link
Author

When I console.log my response data, I get the following

Data is: {
"errorCode": 0,
"message": "[unauthorized]. OAU:'my-linkedin-api-key'|'my-linkedin-api-secret'|_01|_01:1348726250:7N+ZYCyJm7RWUhjd6aVYt0DfKwU=",
"requestId": "T7DJ2BPT4G",
"status": 401,
"timestamp": 1348725985906
}

@lefnire
Copy link

lefnire commented Nov 17, 2012

this works for me

@mikeal mikeal closed this as completed Aug 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants