I am trying to retrieve access tokens using Linkedin API. I use the linkedin package for python.
from linkedin import linkedin
API_KEY = '*****'
API_SECRET = '******'
RETURN_URL = 'http://localhost:8080/hello' #(this works ok)
authentication = linkedin.LinkedInAuthentication(API_KEY, API_SECRET, RETURN_URL)
print authentication.authorization_url # open this url on your browser
application = linkedin.LinkedInApplication(authentication)
authentication.authorization_code = 'the code obtained from login in in previous link'
authentication.get_access_token()
I get the following error:
---------------------------------------------------------------------------
LinkedInError Traceback (most recent call last)
<ipython-input-26-a0063ada08a2> in <module>()
----> 1 authentication.get_access_token()
C:\Users\soledad.galli\AppData\Local\Continuum\Anaconda2\lib\site-packages\linkedin\linkedin.py in get_access_token(self, timeout)
113 'client_secret': self.secret}
114 response = requests.post(self.ACCESS_TOKEN_URL, data=qd, timeout=timeout, verify=False)
--> 115 raise_for_error(response)
116 response = response.json()
117 self.token = AccessToken(response['access_token'], response['expires_in'])
C:\Users\soledad.galli\AppData\Local\Continuum\Anaconda2\lib\site-packages\linkedin\utils.pyc in raise_for_error(response)
61 message = '%s: %s' % (response.get('error', error.message),
62 response.get('error_description', 'Unknown Error'))
---> 63 raise LinkedInError(message)
64 else:
65 raise LinkedInError(error.message)
LinkedInError: invalid_request: missing required parameters, includes an invalid parameter value, parameter more than once. : Unable to retrieve access token : authorization code not found
I have read somewhere else, that this might be because the access tokens have a very short life, however, I manage to copy and paste quite quickly and still get the same error. Any idea why or how to resolve this?
Many thanks