在POST请求Linkedin令牌回溯期间,client_id缺少错误



我想通过在Linkedin中使用令牌内省端点来获取令牌的元数据。

import requests
headers = {"Content-Type": "application/x-www-form-urlencoded"}
client_id=1234
client_secret=4567
token= 435kwer
url = 'https://www.linkedin.com/oauth/v2/introspectToken?client_id={}&client_secret={}&token={}'.format(client_id,client_secret,token)
response = requests.post(url,headers=headers).json()
print(response)

我得到以下错误

{
'error': 'invalid_request', 
'error_description': 'A required parameter "client_id" is missing'
}

我不知道为什么我会犯这个错误。

我使用了以下URL作为参考。

https://learn.microsoft.com/en-us/linkedin/shared/authentication/token-introspection?context=linkedin/context

如果您查看URL 中的示例

curl --location --request POST 'https://www.linkedin.com/oauth/v2/introspectToken' 
--header 'Content-Type: application/x-www-form-urlencoded' 
--data-urlencode 'client_id=<Application Client ID>' 
--data-urlencode 'client_secret=<Application Client Secret>' 
--data-urlencode 'token=<Token Value>'

参数也应该进行编码。因此,如果您将客户端id、客户端secret和令牌放入cURL,您将得到良好的响应。

相关内容

最新更新