Search code examples
restcurloauthcall

How can I change my cURL call to recognise more than 1 parameter?


I want to make the following curl call to get an access token:

curl -k -XPOST --user "{user}" {url}/access_token -d 'grant_type=authorization_code&code={code}&redirect_uri={uri}' 

However, I get the following error statement:

'code' is not recognized as ane internal or external command, operable program or batch file.
'redirect_uri' is not recognized as ane internal or external command, operable program or batch file.

When I check the trace, I see that the body only contains this: 'grant_type=authorization_code

What can I do to make sure all the parameters get passed?


Solution

  • curl -X "POST" "{url}/access_token" \
     --user "{user}" \
     -H "Content-Type: application/x-www-form-urlencoded" \
     --data-urlencode "code={code}" \
     --data-urlencode "redirect_uri={uri}" \
     --data-urlencode "grant_type=authorization_code"
    

    I hope this helps