We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Api Key Redirect URI for multiple subdomains?

JordanC84
Regular Participant

Api Key Redirect URI for multiple subdomains?

Hello,

 

I am integrating out application with CC.

At first I was under the impression our users would have to make their own API key, we would store their key and consumer secret, get the access_token and away we go.

 

Then I read a post which we could host the API key, and have our multiple different clients integrate to our app without entering any parameters (Just the OAuth log in that's prompted).

 

Now here's the problem, our system is divided into multiple subdomains (example.whatever.com, example2.whatever.com), yet hosted on the same server.  Is there a way for us to use the API key with multiple subdomains, considering the redirect URI?  (Wildcard parameters?)

 

Thanks,

 

Jordan Clark

4 REPLIES 4
Shannon_W
Employee

Hi Jordan,

 

The simplest solution I can think of would be to make as many API Keys for your account as subdomains ( e.g. 5 subdomains, 5 API Keys, each with an appropriate redirect URI).  One account can have an unlimited number of API Keys.  Your users still wouldn't have to generate their own API keys--you would do that in advance, they would go through the OAuth2 process, and you would store their access tokens.

 

Best Regards,

Shannon W.

API Support Specialist

JordanC84
Regular Participant

Thanks Shannon for your quick reply!

 

I don't think manually creating an API key for each customer is realistic in our scenario, so we will have a walkthrough for  customers to create their own API key - which we will then store and use.

 

Thanks again,

 

Jordan Clark

An alternate solution could be to use a single domain for the redirect, use a query parameter on that redirect URL to specify which subdomain the request initiated from and then on the single shared redirect URI, do a 302 redirect to the appropriate subdomain with the appropriate information.  This would allow you to use a single API key, single redirect URI but still maintain the sub-domain architecture your set up for with your customers.

Dave Berard
Senior Product Manager, Constant Contact
JordanC84
Regular Participant

That's an amazing idea Dave, thanks!  I'm going to try it over the weekend.

 

I'll let you know how it turns out!

 

Jordan Clark

Developer Portal

View API documentation, code samples, get your API key.

Visit Page