LinkedIn API “Empty oauth2 access token” error

眉间皱痕 提交于 2019-12-13 00:57:18

问题


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.


回答1:


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.




回答2:


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

https://docs.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()


来源:https://stackoverflow.com/questions/54961991/linkedin-api-empty-oauth2-access-token-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!