V3 - Starter .NET Project

Highlighted
Advisor

Re: V3 - Starter .NET Project

You may be able to automated that if you make the user simply go to some web  page you create (once) and use a modified version of the code I posted to store auth and refresh tokens on a per-user basis rather than globally, as I do.

Highlighted
Occasional Participant

Re: V3 - Starter .NET Project

Has anyone got this to work in an unattended process? The only OAuth flows they provide appear to require user interaction to get the code, which completely eliminates batch jobs that run at 1AM to upload contacts and send out emails. Or am I missing something?

Highlighted
Occasional Advisor

Re: V3 - Starter .NET Project

You only need to do the manual process once.  From then on, it works without any further manual interaction. 

 

Step 1 (manual-one time):  Call the URL to get an authorization code.  I have it respond to local host, which errors, but you can get the authorization code from the response URL:  

https://api.cc.email/v3/idfed?client_id=<redacted>&redirect_uri=https%3A%2F%2Flocalhost&response_type=code&scope=account_read+account_update+contact_data

 

Step 2 (only necessary the first time):  Calls return both an authorization code and a refresh_token.  Save the refresh_token in a file and use the authorization code for any API calls:   

https://idfed.constantcontact.com/as/token.oauth2?code=' + self.authorization_code + '&redirect_uri=https://localhost&grant_type=authorization_code

 

Step 3:  Get a new authorization code and refresh_token (saving to a file) once the authorization_code from step 2 expires:  

https://idfed.constantcontact.com/as/token.oauth2?refresh_token=' + refresh_token + '&grant_type=refresh_token

 

 

So, I do step 1 and step 2 once.

I do step 3 every time I run my app from then on.

 

(Note, It's been several months since I last worked on my code, so I hope I've responded accurately). 

Highlighted
Occasional Participant

Re: V3 - Starter .NET Project

Doesn't work unfortunately. I am able to get a authorization code / refresh token interactively using both the browser and postman. But I am unable to do it from my program.

 

Our program only runs once every few days, and the token retrieved would have expired long before I would be able to use it.

 

Unless Refresh tokens live forever?

Highlighted
Advisor

Re: V3 - Starter .NET Project

the refresh token is long lived.   use it, it is going to work in getting you the next pair of auth code/ refresh token

Highlighted
Advisor

Re: V3 - Starter .NET Project

Yes.  The RefreshToken is what you use as it lives forever ... or so it seems.  Simply be sure to ask for and store the new RefreshToken for use next time.

Developer Portal

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

Visit Page

Register for our "Making Sense of Online Marketing for Education" Webinar

Join us on Thursday, August 27th at 2pm ET for a free one-hour webinar where we will be covering how to incorporate online marketing into your educational marketing strategy.

Read More
Featured