OAuth Bad Request Error

969 views
Skip to first unread message

Tracy L

unread,
Sep 28, 2011, 10:29:53 AM9/28/11
to MailChimp API Discuss
I am attempting to integrate MailChimp into our application through
the use of API. I am having an issue with part of the OAuth2
process. I am referencing the documentation at http://apidocs.mailchimp.com/oauth2/.

At this location there is a section titled "Full Flow with request/
response data". I am at Step 4 - "Your application must make an out-
of-band request to the access_token_uri using the "code" returned".

I am using the HttpWebRequest objects in C# (.NET 4 Framework) to make
this request. I continually get the HTTP Response "400 Bad Request".

I have been able to capture the actual HTTP request being made at this
point (see below with some keys modified slightly).

Could someone provide me some insight as to what is "bad" with this
request?

Thanks,
Tracy

Request
===============================================

POST /oauth2/token HTTP/1.1
User-Agent: oauth2-draft-v10
Accept: application/json
Content-Type: application/x-www-form-urlencoded
Host: login.mailchimp.com
Content-Length: 208
Connection: Keep-Alive

grant_type=authorization_code&client_id=xxxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&code=b96b1401820d270e56228dd977c66c2a&redirect_uri=http
%3a%2f%2f127.0.0.1%3a63305%2fMailChimp-Authorize.aspx


==============================================

jesse

unread,
Sep 28, 2011, 11:52:27 AM9/28/11
to MailChimp API Discuss
The redirect_uri we have from when the auth code was created is
different from the redirect_uri configured for your application.
Specifically it has a bunch of extra request parameters tacked on to
the end of the configured url.

You may also want to just try this:

https://github.com/jamierytlewski/eepOAuth2-MVC


jesse


On Sep 28, 10:29 am, Tracy L <mslivet...@gmail.com> wrote:
> I am attempting to integrate MailChimp into our application through
> the use of API.  I am having an issue with part of the OAuth2
> process.  I am referencing the documentation athttp://apidocs.mailchimp.com/oauth2/.

Tracy L

unread,
Sep 28, 2011, 6:04:06 PM9/28/11
to MailChimp API Discuss
Thanks for the response. It helped. The extra parameters weren't the
issue, but once I made the ones on the call to the access_token_uri
match the ones used on the call to the authorize_uri, everything
worked fine.

Thanks,
Tracy
> > grant_type=authorization_code&client_id=xxxxxxxxxxxx&client_secret=xxxxxxxx­xxxxxxxxxxxxxxxxxxxxxxxx&code=b96b1401820d270e56228dd977c66c2a&redirect_uri­=http
> > %3a%2f%2f127.0.0.1%3a63305%2fMailChimp-Authorize.aspx
>
> > ==============================================

ajax

unread,
Jul 12, 2012, 1:39:38 PM7/12/12
to mailchimp-...@googlegroups.com
Hi Tracy 

Actually i am getting  very same Bad request exception and this solution did not worked for me
 
Even i tried your code from github with my credentials , and got same bad request exception?

Any clue how to fix it ? 

Thanks,
Ajay 

jesse

unread,
Jul 13, 2012, 7:26:21 AM7/13/12
to mailchimp-...@googlegroups.com
I'll just assume you are talking about the PHP example app. I just tested it and it still works, so the first thing to do is double check you actually have entered the proper information in the proper places. As with this original post, that's typically the issue if you have issues with it. You may also want to make sure you've actually read through the docs while using the sample code:
http://apidocs.mailchimp.com/oauth2/


jesse
Reply all
Reply to author
Forward
0 new messages