400 Bad request when getting OAuth token

2,119 views
Skip to first unread message

John Gwaltney

unread,
Dec 9, 2013, 11:01:55 AM12/9/13
to mailchimp-...@googlegroups.com
Hi, I'm trying to get an OAuth token using the API but I keep getting a 400 Bad Request error when I try to retrieve the token using the code returned.  Here's an example request:

POST /oauth2/token HTTP/1.1
Host: login.mailchimp.com
Accept-Encoding: gzip, deflate
User-Agent: RSSBus Data Provider Engine - www.rssbus.com
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 173

grant_type=authorization_code&client_id=xxxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&code=d64bf9270586c4756685e483fd3decf4&redirect_uri=http%3a%2f%2f127.0.0.1

The Client Id, Client Secret, and Redirect URI are all exactly as they appear for my registered app so I'm not sure what's bad about the request.  I'm using the exact same values when I make the request for the code.  Do you see anything obvious that I'm doing wrong?  I've tried lots of small variations of the above but I always get the same 400 error.

Adam Marton

unread,
Dec 12, 2013, 10:13:07 AM12/12/13
to mailchimp-...@googlegroups.com
Same here.
Do you have any progress on this?

Dano McKagan

unread,
Jan 9, 2014, 1:41:02 AM1/9/14
to mailchimp-...@googlegroups.com

From this:

it appears that the redirect_uri must match the one used when passed to the MailChimp login page.

When I had this problem, the redirect_uri for the two different requests (MC login page, out-of-band request to get the access token) were the same except the former had a query string (customer_id=XXXXXXX) and the latter did not.  Making them the same, adding the query string to the latter, fixed it.

Dano!
Reply all
Reply to author
Forward
0 new messages