python-linkedin icon indicating copy to clipboard operation
python-linkedin copied to clipboard

cannot get access token

Open zhiyzuo opened this issue 9 years ago • 8 comments

Maybe this is a dumb question but I'm totally new to apis and hope to get help.

I am following the instructions in the readme file and when I proceeded to

authentication.authorization_code = '???' authentication.get_access_token()

I got this error:

linkedin.exceptions.LinkedInError: invalid_request: missing required parameters, includes an invalid parameter value, parameter more than once. : Unable to retrieve access token : appId or redirect uri does not match authorization code or authorization code expired

I'm using http://localhost:8000 as the return_url. I pasted the link the python printed and got the authorization_code and use it in the above code but got the error.

Someone help me out please...Really have no idea...

zhiyzuo avatar Oct 01 '14 01:10 zhiyzuo

me too! Does the return url really matters? Need I change the http://localhost:8000 to some www.XXX.com ? Help me!

baisk avatar Nov 14 '14 09:11 baisk

afaik the return url really matters and it has to be registered in linkedIn api settings

cleder avatar Nov 14 '14 11:11 cleder

I also registered https://localhost:8000 in linkedin api settings.

Now the problem is, I can only use the application for once. I forgot to remember the result of authentication.get_access_token(). I run the program again, input the authorization_code again, and got an error.

baisk avatar Nov 14 '14 11:11 baisk

I guess the old authorization_code may still be valid, and it prevent another get_access_token() ?

baisk avatar Nov 14 '14 11:11 baisk

Strange, I am pretty sure that you can request access tokens without limit. It would be impossible to log in from different devices/browsers at the same time with this being forbidden.

cleder avatar Nov 14 '14 11:11 cleder

Could one user get two access tokens in the same time?

baisk avatar Nov 18 '14 01:11 baisk

# -*- coding: utf-8 -*-
#!/usr/bin/env python
# @author: baisk <[email protected]>
from linkedin import linkedin

# API_KEY = 'wFNJekVpDCJtRPFX812pQsJee-gt0zO4X5XmG6wcfSOSlLocxodAXNMbl0_hw3Vl'
# API_SECRET = 'daJDa6_8UcnGMw1yuq9TsjoO_PMKukXMo8vEMo7Qv5J-G3SPgrAV0FqFCd0TNjQyG'

API_KEY = '75ikzf7tubpe8b'
API_SECRET = 'mG3ujuLsVfTEQukr'
RETURN_URL = 'https://localhost:8000'

# 注意这里的scope不能超过设置api时候的范围, 否则会超出权限而报错, 并且错误看不出来.
authentication = linkedin.LinkedInAuthentication(API_KEY, API_SECRET, RETURN_URL) #, linkedin.PERMISSIONS.enums.values())
print authentication.authorization_url  # open this url on your browser
application = linkedin.LinkedInApplication(authentication)

# https://localhost:8000/?code=AQRQglTv_nL6lGpYT1VuPKRVjgXoyMiibdDNYjzR_v9H9LM4EbdybziDgEbYfEJOOKOkq5vPU0G1g3WVN2djwS6pKnh5tjP6ky1aX_yraRqDpkS9C3g&state=fcb6805995568f449fb6eb4d7c358b22
authentication.authorization_code = 'AQRQglTv_nL6lGpYT1VuPKRVjgXoyMiibdDNYjzR_v9H9LM4EbdybziDgEbYfEJOOKOkq5vPU0G1g3WVN2djwS6pKnh5tjP6ky1aX_yraRqDpkS9C3g'
print authentication.get_access_token()

# print application.get_profile(selectors=['id', 'first-name', 'last-name', 'location', 'distance', 'num-connections', 'skills', 'educations'])
print application.get_profile()

# -*- end of file -*-

baisk avatar Nov 18 '14 02:11 baisk

I get "The redirect_uri does not match the registered value" when logging to authentication.authorization_url

chfakht avatar Oct 07 '18 23:10 chfakht