CORS blocks LinkedIn share API

All we need is an easy explanation of the problem, so here it is.

I try to post new content using LinkedIn share API through JavaScript from AngularJS application as given below.

var xml = "<share><comment>" + content + "</comment><visibility><code>anyone</code></visibility></share>";

var req = {
   method: 'POST',
   url: '' + account.token,
   headers: {
       'Content-Type': 'text/plain'
   data: xml

$http(req).success(function(data) {
   console.log('published to linkedin');
}).error(function() {
   console.log('failed to publish to linkedin');

I can successfully POST this data. However the browser blocks the response from being read because the response doesn’t have an ‘Access-Control-Allow-Origin’ header.


But, I have given the http://localhost:3000 and ‘https://localhost:3000‘ domains in LinkedIn application settings.

LinkedIn Application Settings

And the request/response in Chrome looks like this.

Failing request response

Any thoughts on how to be able to read the response and not let the browser block it?

I think the problem is the missing Access-Control-Allow-Origin header in the LinkedIn API response?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Looks like LinkedIn’s REST API doesn’t support CORS. They suggest to use REST API from the backend and not from browser. JS-SDK must be used from the browser.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply