BAD_REDIRECT_URI on OAuth Token Request

I’m currently trying to get OAuth access tokens via curl. My curl request is as follow:

curl -X POST \
-H "Content-Type: application/x-www-form-urlencoded;charset=utf-8" \
https://api.hubapi.com/oauth/v1/token \
-d grant_type=authorization_code\
&client_id=<my_client_id>\
&client_secret=<my_client_secret>\
&redirect_uri=https://www.example.com/\
&code=<code>

The actual redirect_uri doesn’t seem to matter, no matter what I use, I get this error:

{
	"status": "BAD_REDIRECT_URI",
	"message": "missing or unknown redirect URI",
	"correlationId": "a21020ee-fef2-44a4-a990-ad6c5e5f331c",
	"requestId": "e81f1973945f58f665852606c88cd292"
}

I have tried encoding the redirect_uri as a URI component and wrapping it in quotes. I keep getting the same error.

Thank you!

I figured out the issue. I wasn’t submitting the curl request in the proper format. It should have looked like this:

curl -X POST \
-H "Content-Type: application/x-www-form-urlencoded;charset=utf-8" \
https://api.hubapi.com/oauth/v1/token \
-d "grant_type=authorization_code&client_id=<my_client_id>&client_secret=<my_client_secret>&redirect_uri=https://www.example.com/&code=<code>"

The data body should have been wrapped entirely in quotes.