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.

V3 API: Retrieve the Authorization Code

SOLVED
Go to solution
CarolynG105
Regular Participant

V3 API: Retrieve the Authorization Code

I'm trying to figure out how to retrieve the Authorization Code programmatically.

On the OAuth2.0 Server Flow -> Step 4 :  How do you login programmatically to get the Authorization code?

The URL takes you to a login page where you need to enter your user id and password.

 

https://api.cc.email/v3/idfed?client_id=#clientID&redirect_uri=https://localhost&response_type=code

 

https://v3.developer.constantcontact.com/api_guide/server_flow.html

1 ACCEPTED SOLUTION

Hello Everyone,

 

Just to answer a question that has not been answered by others in this thread.

 

The Refresh Token does not expire. It can be invalidated if you go through the full oAuth process again to create a new Access/Refresh Token. Once you generate the first pair of Access/Refresh Tokens as long as you only go through Step 5 which is the refresh flow then you will not have to worry about invalidating previously generated tokens.


Regards,
Jimmy D.
Tier II API Support Engineer

View solution in original post

8 REPLIES 8
raleighb3
Member

if i understand your question correctly, the answer is this:   the first time you go through this process, the User must login manually in order to allow access.   Once they grant access, you receive both an Access Token and a Refresh Token.   That Refresh Token can be used as needed to to get another Access Token.  When the Refresh Token is used to get Access Token, no manual User action is necessary because your code can perform this function.

Hope that helps.

Thanks for the reply.  Does the refresh token ever expire?  

 

This is what I'm trying to accomplish.

When a new user signs up on our website,  we are going to add them to Constant Contact.  The user that signed up on our website, does not know anything about Constant Contact.  

 

Thanks again.

i am uncertain as to if/when/how a Refresh Token expires, if ever.   but, you do receive a new Refresh Token each time you use a Refresh Token to obtain a new Access Token

.   

As stated in the CC docs:  "...Access tokens automatically expire two hours (7,200 seconds) after their last use. Access tokens have a maximum lifetime of 24 hours (86,400 seconds)...."

 

here is a helpful link to info on Tokens and even a good Refresh strategy:    https://v3.developer.constantcontact.com/api_guide/faqs_manage_applications.html

edit:   look under the "Make access tokens last longer?" topic on that link

Hello Everyone,

 

Just to answer a question that has not been answered by others in this thread.

 

The Refresh Token does not expire. It can be invalidated if you go through the full oAuth process again to create a new Access/Refresh Token. Once you generate the first pair of Access/Refresh Tokens as long as you only go through Step 5 which is the refresh flow then you will not have to worry about invalidating previously generated tokens.


Regards,
Jimmy D.
Tier II API Support Engineer

View solution in original post

Sorry to say, yes, the refresh_token does indeed expire.

 

Maybe you can make a simple HTML/PHP form with a video showing us what you are doing?

For example: 

  • Document how to add 1 user
  • to a specific list
  • with 2 custom fields
  • from a simple landing page with a custom form
  • with a hardcoded API Key, Secret and Token - that does not expire

 

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 V3 refresh token does not expire unless it is used or a new refresh token has been generated. Refresh tokens can only be used once, as generating a new set of tokens causes all previous tokens to expire. 

 

You will need to set the access token and the refresh token as values for corresponding variables in your application, so that when your program runs through step 5 of the OAuth2.0 Server Flow to get the new set of tokens it can assign new values to those variables to maintain an authenticated connection.

 

V3 API - Refresh the Access Token

https://v3.developer.constantcontact.com/api_guide/server_flow.html#step-5-refresh-the-access-token

 

How to Make Access Tokens Last Longer

https://developer.constantcontact.com/api_guide/faqs_manage_applications.html

 

The request for V3 application code samples is currently under review. However, we're currently still adding endpoints and capabilities to the V3 API, and do not plan to publish official SDKs or sample apps until that process is complete. Your feedback and experience with this request is essential to improving our product, so thank you for reaching out to us regarding this matter.

 

In the meantime, here are the example calls that are currently available for V3:

 

V3 Code Samples:

https://v3.developer.constantcontact.com/api_guide/tag_code_samples.html


Regards,

Courtney E.
API Support Specialist

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.
Stacyw744
Regular Participant

This question has been marked solved, but it's really not solved. 

 

If you have a website where users create accounts (a store or membership type site), it seems like you can't just add them to your Constant Contact list during the account create - it has to be done in a completely separate admin flow so the Constant Contact accountholder can authenticate and permit adding to the list.   

Correct... sadly... so far we have the same problem:

impossible to "add 1 user to a specific list with some custom fields from a simple PHP landing page with a custom form"

 

Ergo: Not solved

Developer Portal

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

Visit Page