Search code examples
oauth-2.0linkedin-api

How to renew expired LinkedIn access token


I'm trying to renew my expired access token like the documentation:

https://developer.linkedin.com/documents/authentication

I'm trying to make GET requests like this:

First GET (used to get code):

https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=XXX&scope=r_fullprofile&state=hyriedsdsv56uvenn5eouvnjedfgdfgio5&redirect_uri=http://www.MY_DOMAIN.com

The return of this request is something like this:

http://www.MY_DOMAIN.com/?code=MY_CODE&state=hyriedsdsv56uvenn5eouvnjedfgdfgio5

After this, I have to make the final request to get my access token:

https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code=XXX&redirect_uri=http://www.MY_DOMAIN.com&client_id=XXX&client_secret=XXX

And LinkedIn is returning this error message:

{"error":"invalid_request","error_description":"missing required parameters, includes an invalid parameter value, parameter more then once. : Unable to retrieve access token : appId or redirect uri does not match authorization code or authorization code expired"}

Does anyone know what should I do to fix this? My authorization token can`t be expired because I'm using at the time that I get one.

I am using the correct key and app secret.

Thank you! =)


Solution

  • 20 second seems expiration time between the two. Your domain.com/.. should immediately make a accessToken call and store it in client DB.