# BAD\_REDIRECT\_URI on OAuth Token Request

**URL:** <https://community.hubspot.com/t/bad-redirect-uri-on-oauth-token-request/13710>\
**Category:** APIs & Integrations\
**Tags:** developer-tools, oauth, contacts\
**Created:** [March 27, 2019, 3:52pm UTC](https://community.hubspot.com/t/bad-redirect-uri-on-oauth-token-request/13710 "2019-03-27T15:52:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dougyan12](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dougyan12/32/98942_2.png) [@dougyan12](https://community.hubspot.com/u/dougyan12)\
**Post date:** [March 27, 2019, 3:52pm UTC](https://community.hubspot.com/t/bad-redirect-uri-on-oauth-token-request/13710/1 "2019-03-27T15:52:13Z")

</div>

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

```auto
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:

```auto
{
	"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!

---

<div class="post-metadata">

**Author:** ![dougyan12](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dougyan12/32/98942_2.png) [@dougyan12](https://community.hubspot.com/u/dougyan12)\
**Post date:** [March 27, 2019, 7:41pm UTC](https://community.hubspot.com/t/bad-redirect-uri-on-oauth-token-request/13710/2 "2019-03-27T19:41:28Z")

</div>

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

```auto
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.
