client_id is missing error during POST request for Linkedin Token Retrospection

Viewed 364

I want to get token's metadata by using token introspection endpoint in 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)

I get the following error

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

I don't know why am I getting this error.

I used the following URL as a reference.

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

1 Answers

If you take a look at the example from the 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>'

The parameters should be encoded, too. So, if you put the client id, the client secrete, and the token into the cURL you will get a good response.

Related