The Silver Lining

Lessons & Learnings from a salesforce certified technical architect.

Salesforce & LinkedIn Developer API: 401 – Unauthorized

with 3 comments

Image representing LinkedIn as depicted in Cru...

Image via CrunchBase

I’m not going to get into the boilerplate code you’ll need in order to get OAuth up and running as it’s pretty straight forward, but I did run into a peculiar issue which took me some time to narrow down. To reproduce these steps you’ll need to:

  1. Correctly setup OAuth between the Force.com Platform and LinkedIn
  2. Authorise access to your LinkedIn account
  3. Attempt to fetch a resource using an API endpoint such as: http://api.linkedin.com/v1/people/~/network/updates?scope=self

When attempting to make the call out in step 3 you’ll get a “401 – Unauthorized” error. So to be clear OAuth is working perfectly but a call like this one will still result in the error.

After some troubleshooting I noticed that some API endpoints didn’t result in the error e.g. http://api.linkedin.com/v1/people/id=abcdefg/network/updates?scope=self. At this point I realised the issue was probably the tilde (‘~’) character in the URI.

Grasping at straws I manually replaced the tilde with it’s URL friendly equivalent ‘%7E’ and the callout worked perfectly. Now this is strange because I am, in the course of making the callout, URL encoding all parts of the endpoint URL. It seems that for some reason the LinkedIn OAuth services needs to have the tilde encoded twice when signing the request :/

About these ads

3 Responses

Subscribe to comments with RSS.

  1. Good to know.

    d3developer

    March 20, 2011 at 9:47 pm

  2. I am facing the same issue.However I get a proper response for the link ‘http://api.linkedin.com/v1/people/~/network/updates’ but when the link is changed to ‘http://api.linkedin.com/v1/people/~/network/updates?scope=self’ my result matches yours :-/

    Unfortunately encoding the tilde doesnt work for me :(

    Rohit

    April 28, 2011 at 12:32 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 2,203 other followers

%d bloggers like this: