i am trying to generate access token to collect linkedin data. I followed the instructions provided in the linkedin API documentaion. I created an app in developers page and got
Well, I went through the same problem and here is the process which i went through to fix it.
STEP#1: Authentication:
https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=[your_client_id]&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Flinkedin%2Fcallback&scope=r_emailaddress
Once you hit this as a GET request, you will receive a callback with a code
and an optional state
parameter.
STEP#2: Getting Access Token:
There are three pre-requisites to this call:
POST
Content-Type
with value application/x-www-form-urlencoded
redirect_url
MUST BE SAME as in the previous call.Now the trick here is, that the call in (STEP#1 Authentication) was a GET request. Therefore, the redirect_url
had to be programatically encoded.
Since the second call for is POST
and is also application/x-www-form-urlencoded
encoded, therefore the request body parameters do not have to be explicitly encoded. So, in this case, the redirect_uri
would be sent as-is (http://localhost:8080/linkedin/callback)
Here is a snapshot of my Access Token API via postman: