I am using AngularJS 1.5.8 and trying to implement Linkedin API.
Linkedin authorization has two steps:
1. Request an Authorization Code
I successfully passed this step and received authorization code
2. Exchange Authorization Code for an Access Token
I am trying to send POST request and it fails. Not sure what I am doing wrong. The code looks like this:
var url = 'https://www.linkedin.com/oauth/v2/accessToken';
var params =
{
'grant_type':'authorization_code',
'code': CODE,
'redirect_uri': REDIRECT_URL,
'client_id': CLIENT_ID,
'client_secret': CLIENT_SECRET
};
$http({
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
url: url,
data: params
})
.success(function (result) {
console.log(result);
}).error(function (data, status, header, config) {
console.log(data, status, header, config);
});
Every time I've got next error:
Please, help to fix this.
Many thanks