6

Sorry if this is question is not suitable for stackoverflow.

I've got access token from Linkedin API. I am trying to use it however I am not sure how to include my access_token. I cannot find any example on documentation.

base_url = f'https://api.linkedin.com/v2/people?access_token={linkedin_key}&format=json'
requests.get(base_url).json()

This outputs

    {'serviceErrorCode': 65604,
 'message': 'Empty oauth2 access token',
 'status': 401}

does anyone know what's wrong? Thank you.

0

3 Answers 3

11

The access token param you need to pass is oauth2_access_token not access_token.

For example:

https://api.linkedin.com/v2/me?oauth2_access_token={linkedin_key}

I can't find it in the docs and it's been a while, but that's how I use it in my app.

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you for your help! do you know how to look at all of job posting of specific job? ex: I want to look at all job postings of the role, data scientist.
That I don't know. You will have to look at their docs. I'm also afraid the jobs API may be restricted to their marketing partners.
any solution till yet because i am also suffering from this issue ?
Had similar problems with out of date online references and the usual vague and ambiguous API docs. This works.
@ErvinKalemi from where you will get access_token?
4

I think they want you to pass it in the headers based on my reading of their docs

https://learn.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?context=linkedin/context#step-4-make-authenticated-requests

requests.get(base_url,headers={"Authorization":"Bearer {access_token}"}).json()

2 Comments

it tells me that I need to add format at the end. in such case do I add it at base_url? which will become base_url = 'api.linkedin.com/v2/people?~format=json'
FWIW, when passing the same valid token via HEADER and GET at the same time I get {'serviceErrorCode': 65603, 'message': 'Multiple access token provided', 'status': 401} hinting at both types of auth being seen, at a bare minimum.
-1

You shouldn't try to include it directly in header. Instead go to the Authorization tab, select OAuth2.0 and give access token there. Refer to the imageenter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.