LinkedIn API“空 oauth2 访问令牌”错误

lmb*_*loo 4 python api linkedin-api

对不起,如果这个问题不适合 stackoverflow。

我从 Linkedin API 获得了访问令牌。我正在尝试使用它,但是我不确定如何包含我的 access_token。我在文档中找不到任何示例。

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

这输出

    {'serviceErrorCode': 65604,
 'message': 'Empty oauth2 access token',
 'status': 401}
Run Code Online (Sandbox Code Playgroud)

有谁知道怎么了?谢谢你。

Erv*_*emi 10

您需要传递的访问令牌参数oauth2_access_token不是access_token.

例如:

https://api.linkedin.com/v2/me?oauth2_access_token={linkedin_key}
Run Code Online (Sandbox Code Playgroud)

我在文档中找不到它并且已经有一段时间了,但这就是我在我的应用程序中使用它的方式。


Jor*_*ley 4

我认为他们希望您根据我对他们文档的阅读将其传递到标题中

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()
Run Code Online (Sandbox Code Playgroud)