API Connection in R

OliviaSurgere
Rookie
0 Votes

Hello,

 

I am currently having difficulties in connecting to ConstantContact through API in R. Here is the code that I am currently running:

 

cc_app <- oauth_app("constant_contact",
key = "[redacted],
secret = "[redacted]",
redirect_uri = "https://localhost")

 

CCtoken <- oauth2.0_token(endpoint = oauth_endpoint(authorize = "https://authz.constantcontact.com/oauth2/default/v1/authorize", access = "https://authz.constantcontact.com/oauth2/default/v1/token"), app = cc_app)

 

When I run it, I am greeted with a 400 error: Your request resulted in an error. The 'redirect_uri' parameter must be a Login redirect URI in the client app settings: https://prod-ctct-admin.okta.com/admin/app/oidc_client/instance/0oa1sanwcai0kKgL30h8#tab-general.

 

Do I need a different redirect uri? Or is there an error within my code? My end goal is to pull campaign information and total contacts.

1 REPLY 1
Courtney_E
Employee
0 Votes

Hello OliviaSurgere,

 

Thank you for reaching out to Constant Contact API Developer Support. My team is here to assist outside software developers with questions about building into Constant Contact's API.

 

The mismatched_redirect_uri error response is  typically caused when the redirect URI in your Authorization Request doesn't exactly match the redirect URI in your key's settings (https://app.constantcontact.com/pages/dma/portal/).

 

One additional thing I did want to mention as well:

 

While it won’t return any errors if excluded from your Authorization Request, you’ll want to also include the new scope “offline_access”, which is now required for returning refresh tokens

 

Like so:

scope=contact_data+campaign_data+offline_access

 

Here is how your initial Authorization Request URL should be formatted:

 

GET https:// authz.constantcontact.com/oauth2/default/v1/authorize?client_id=________________&scope=________________+offline_access&response_type=code&state=________________&redirect_uri=________________

 

Step 1: Create an Authorization Request

https://v3.developer.constantcontact.com/api_guide/server_flow.html#step-1-create-an-authorization-r...

 

Please have a look and let us know if you have any other questions!


Regards,

Courtney E.
Tier II API Support Engineer

Did I answer your question?
If so, please mark my post as an "Accepted Solution" by clicking the Accept as Solution button in the bottom right hand corner of this post.
Resources
Developer Portal

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

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up