cancel
Showing results for 
Search instead for 
Did you mean: 

Authorization Code Request: 400 - Invalid redirect_uri when adding query parameters

Occasional Organizer

Authorization Code Request: 400 - Invalid redirect_uri when adding query parameters

Hi,

 

I'm in the process of implementing OAuth 2.0 server flow authentication on my platform which serves multiple organizations with each their specific URL. Thus, on the Authorization Request call, I have to make use of additional query parameters by appending them to the redirect URI and encoding them to redirect my users after a successful authentication. Alas, adding any additional query parameters to my redirect URI gives me a 400 - Invalid redirect_uri error page indicating a mismatch between the redirect URI specified in the call and the one on my application settings.

 

Here's the redirect URI specified in my application settings:

http://www.amilia.localhost/Ws/ConstantContact/OAuthResponse

 

Here's the non-encoded redirect URI and appended query parameters I'm sending with the Authorization Request:

http://www.amilia.localhost/Ws/ConstantContact/OAuthResponse?orgId=3049

 

Here's the complete Authorization Code Request as I'm sending it to your servers with redacted Client ID:

https://api.cc.email/v3/idfed?response_type=code&client_id=<MY_CLIENT_ID>&scope=contact_data&redirect_uri=http%3a%2f%2fwww.amilia.localhost%2fWs%2fConstantContact%2fOAuthResponse%3forgId%3d3049

 

Here's the C# code responsible for redirecting the user to Constant Contact's servers for the Authorization Code Request:

 

public void AuthorizationCodeRequest(int orgId)
{
    var apiKey = <MY_CLIENT_ID>
    var redirectParams = $"?orgId={orgId}";
    var redirectUrl = HttpUtility.UrlEncode("http://www.amilia.localhost/Ws/ConstantContact/OAuthResponse" + redirectParams);
            
    var url = $"https://api.cc.email/v3/idfed?response_type=code&client_id={apiKey}&scope=contact_data&redirect_uri={redirectUrl}";

    HttpContext.Current.Response.Redirect(url);
}

 

With no additional query parameters, the authentication works fine and I'm able to get an Access Token with the returned code but as soon as I add any additional query parameters, I am met with the 400 - Invalid redirect_uri error page. I am not sure as to what I'm doing wrong here as adding query parameters to the redirect URI is supported as specified in the V3 API documentation.

4 REPLIES
Moderator

Re: Authorization Code Request: 400 - Invalid redirect_uri when adding query parameters

Hi @KristenG703,

 

I am currently looking in to this. Our v2 API works with this and our documentation and developers say this should work in the v3 API; however I'm having the same issue as you are.

 

Let me do a little more digging/testing on this and see what I can come up with.


Regards,
Jimmy D.
Tier II API Support Engineer
Visitor

Re: Authorization Code Request: 400 - Invalid redirect_uri when adding query parameters

As a developer, I sort of hate it when people tell me the following:

 

Hey, it's happening to me too.

 

But...hey it's happening to me too and I don't want to resort to Cookies or Local Storage to try to manage state unless this is going to be a long time to fix.  Without this capability it will be hard for us to know who we passed to constant contact.  I am sure you get that.

Visitor

Re: Authorization Code Request: 400 - Invalid redirect_uri when adding query parameters

Can we get an update on this issue as it is preventing me from moving forward.

Highlighted
Moderator

Re: Authorization Code Request: 400 - Invalid redirect_uri when adding query parameters

Hi @ERICW916,

 

I have brought this up to our engineers and they are looking in to it. At this time I do not have an ETA; however if you would like an email when the issue is resolved you can email us at webservices@constantcontact.com and we can set that up.


Regards,
Jimmy D.
Tier II API Support Engineer
Still need help?
You can post a new message in the Community or find us on Twitter Mon-Fri 8am - 8pm ET. We've got real people waiting to help you out. Click below to start a conversation!