0

I am connecting to linkedin api through python.

url = 'https://www.linkedin.com/uas/oauth2/accessToken'

data = [
        {'client_id': 'xxx'},
        {'client_secret': 'xxx'},
        {'grant_type': 'authorization_code'},
        {'redirect_uri' : 'xxx'},
        {'code': xxx}
      ]

headers = {'Content-type': 'application/x-www-form-urlencoded'}
r = requests.post(url, data=json.dumps(data), headers=headers)
return HttpResponse(r)

but I am getting the following error :

{"error_description":"missing required parameters, includes an invalid parameter value, parameter more than once. : client_id","error":"invalid_request"}

what is the reason for this error ? how to debug ? please help.

0

1 Answer 1

1

That is a strange way to format the data. You have each parameter in a separate dictionary. I guess you want a single dict:

data = {
         'client_id': 'xxx',
         'client_secret': 'xxx',
         'grant_type': 'authorization_code',
         'redirect_uri' : 'xxx',
         'code': xxx
       }

Also, you specify the content type as form-encoded, but you then serialize the actual data as JSON. Don't do that.

r = requests.post(url, data=data, headers=headers)
Sign up to request clarification or add additional context in comments.

1 Comment

Getting error {"error_description":"missing required parameters, includes an invalid parameter value, parameter more than once. : Unable to retrieve access token : appId or redirect uri does not match authorization code or authorization code expired","error":"invalid_request"}

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.