1
我试图使用Linkedin API检索访问令牌。我使用用于python的linkedin软件包。Linkedin API:无法使用Python中的Linkedin API获取访问令牌
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()
我收到以下错误:
---------------------------------------------------------------------------
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
我看过其他地方,这可能是因为访问令牌有一个寿命很短,但我设法复制并很快贴并仍然有相同的错误。任何想法为什么或如何解决这个问题?
非常感谢