Closed alceal closed 7 years ago
Can you please send your code and the error message? I can't help like this
I created a linkedin application and got the keys:
This is my script:
APPLICATON_KEY = '77m******************'
APPLICATON_SECRET = '5ok******************'
RETURN_URL = 'http://localhost:8080'
authentication = linkedin.LinkedInAuthentication(APPLICATON_KEY,
APPLICATON_SECRET,
RETURN_URL,
linkedin.PERMISSIONS.enums.values())
print(authentication.authorization_url)
Then I followed the instructions:
Okay, for what I can see right here, at least two things mismatches:
You need to have exactly the same things on both sides
By the way, your permission are wrong ... You can not requests all of the possible ones (like in the demo).
For recall the followings are available via the PERMISSIONS enum, you need to match the settings and the one declared in the LinkedIn Dev Console ;)
PERMISSIONS = enum('Permission',
# Default Permissions
BASIC_PROFILE='r_basicprofile',
EMAIL_ADDRESS='r_emailaddress',
SHARE='w_share',
# Company Permissions
COMPANY_ADMIN='rw_company_admin',
# Permissions you need to apply to : https://help.linkedin.com/app/ask/path/api-dvr
FULL_PROFILE='r_fullprofile',
CONTACT_INFO='r_contactinfo'
)
I've changed:
My callback URL on the LinkedIn Dev Panel = http://localhost:8080 My callback URL in the application = http://localhost:8080 My code:
from linkedin import linkedin
APPLICATON_KEY = '77m******************'
APPLICATON_SECRET = '5ok******************'
RETURN_URL = 'http://localhost:8080'
authentication = linkedin.LinkedInAuthentication(APPLICATION_KEY,
APPLICATION_SECRET,
RETURN_URL,
permissions='r_basicprofile')
print(authentication.authorization_url)
But I got this new error:
Solved:
authentication = linkedin.LinkedInAuthentication(APPLICATION_KEY,
APPLICATION_SECRET,
RETURN_URL,
permissions=['r_basicprofile'])
Permissions must be in a list.
The auth code is with &state=?
#############################################&state=########################
I've tried both options: w/ and w/o &state= but I got the same error:
Traceback (most recent call last):
File "/Users/alceal/Dropbox/Projects/Python/.virtualenvs/linkedin-bot/lib/python3.6/site-packages/linkedin/utils.py", line 49, in raise_for_error
response.raise_for_status()
File "/Users/alceal/Dropbox/Projects/Python/.virtualenvs/linkedin-bot/lib/python3.6/site-packages/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://www.linkedin.com/uas/oauth2/accessToken
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "linkedin-bot/linkedin-bot.py", line 19, in <module>
result = authentication.get_access_token()
File "/Users/alceal/Dropbox/Projects/Python/.virtualenvs/linkedin-bot/lib/python3.6/site-packages/linkedin/linkedin.py", line 136, in get_access_token
raise_for_error(response)
File "/Users/alceal/Dropbox/Projects/Python/.virtualenvs/linkedin-bot/lib/python3.6/site-packages/linkedin/utils.py", line 62, in raise_for_error
raise ex(message)
linkedin.exceptions.LinkedInError: invalid_request: Unknown Error
My code:
from linkedin import linkedin
APPLICATON_KEY = '77m******************'
APPLICATON_SECRET = '5ok******************'
RETURN_URL = 'http://localhost:8080'
authentication = linkedin.LinkedInAuthentication(APPLICATION_KEY,
APPLICATION_SECRET,
RETURN_URL,
permissions=['r_basicprofile'])
authentication.authorization_code = '********************************************'
result = authentication.get_access_token()
print ("Access Token:", result.access_token)
print ("Expires in (seconds):", result.expires_in)
Everything is explained here: https://github.com/DEKHTIARJonathan/python3-linkedin#production-authentication
Please mark the issue as solved if everything is working ;)
Sorry but it's not clear -> https://github.com/DEKHTIARJonathan/python3-linkedin#production-authentication
sounds like the doc needs some clarification, @alceal you should send in a pr to update the doc
@jayzeng yeah, someone should get the same result if he follows the doc but this is not the case.
It would be a great pleasure for me to merge any PR regarding the documentation ;) Feel free to fork and help @jayzeng or @alceal
Can I close this issue ?
The invalid redirect_uri issue is solved but I'm still having problems with auth code. I'll try it again later.
@DEKHTIARJonathan everything is working.
I have tried authenticating with OAuth 2.0 according to the instructions but I always get this error. Could anyone help me?