ozgur / python-linkedin

Python interface to the LinkedIn API
http://ozgur.github.com/python-linkedin/
MIT License
893 stars 392 forks source link

Can anyone get the authentication to work at all? #111

Open clivebearmanhub opened 6 years ago

clivebearmanhub commented 6 years ago

Seems like the move to OAuth 2 by LinkedIn has totally broken this library. Even if you follow the instructions and manually copy the authorization code, it fails to retrieve the token and raises an exception. Is this the same for everyone? Or am I just too stupid to get it to work. Any help is gratefully appreciated.

raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://www.linkedin.com/uas/oauth2/accessToken

shroffshivangi commented 6 years ago

Use this:

curl -X POST --http1.1 "https://www.linkedin.com/oauth/v2/accessToken" --cookie "X-Csrf-Token: 987654321" -d "grant_type=authorization_code&code=authorizationcodehere&redirect_uri=http%3A%2F%2Flocalhost%2Fcode&client_id=client_id&client_secret=client_secret" -H "Content-Type: application/x-www-form-urlencoded"

37Rokibul commented 6 years ago

@shroffshivangi can you please tell me how I get -cookie "X-Csrf-Token: 987654321"??? I can do all the things except X-CSRF- TOKEN.

shroffshivangi commented 6 years ago

It's same as the state that you put in the previous step.

37Rokibul commented 6 years ago

@shroffshivangi

Hello, I have a problem. I do not know why invalid requests shows. I am confused about redirect url results are shown below.

invalid_request","error_description":"Unable to retrieve access token: a ppid/redirect uri/code verifier does not match authorization code. Or authorizat ion code expired. Or external member binding exists"

please help me out about this problem.

37Rokibul commented 6 years ago

@shroffshivangi Can you please tell what is the redirect url?? I used emblemidea.com for linkedin app. should I use callback encodeed url or any other url??

shroffshivangi commented 6 years ago

You can use any redirect url, it should just be a valid one.

If the redirect uri is https://www.google.com - Step 1 would be something like this:

https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=your_client_id&redirect_uri=https%3A%2F%2Fwww.google.com&state=987654321&scope=rw_company_admin%20r_emailaddress%20w_share%20r_basicprofile

Note: the scope is what permissions you want your application to have.

37Rokibul commented 6 years ago

@shroffshivangi actually I want to solve step 3. in step 3, in POST method, when I use git bash for get access token via using your 1st comment code sample, I get invalid as result. how can I solve it??

37Rokibul commented 6 years ago

Hey @shroffshivangi , I am regardly waiting for your response. as I can't solve it. please help me in step 3 as documentation.