The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

Need authorization for single stand alone windows app

SOLVED
Go to solution
Highlighted
Occasional Contributor

Need authorization for single stand alone windows app

I want to create an application that queries our Constant Contact data.  It will be a stand-alone Windows application and will only be used by us at one location.  It will not be distributed or used to access any other users CC data. 

 

Do I need to build an entire OAuth mechanism to make this happen when all I really need is one authorization code?

 

Are there any other alternatives?

 

Thank you for any help

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Trusted Contributor

Re: Need authorization for single stand alone windows app

Hello,

 

In your case, if access to your application is otherwise secured,  you could write a client-flow script to obtain an access token for the account your application will access, and simply store that or hard-code it into your application.  I would recommend getting a dedicated API Key for that purpose. I created this example javascript code could easily be used to obtain an access token for this purpose. I'd be inclined to build in an ability to enter a new/udpated access token, in case you ever needed to reauthorize your application, but at this time, our access tokens have a very long lifespan.

 

I hope this is helpful.

 

Cheers,

Mark Coleman
Support Engineer

View solution in original post

7 REPLIES 7
Highlighted
Trusted Contributor

Re: Need authorization for single stand alone windows app

Hello,

 

In your case, if access to your application is otherwise secured,  you could write a client-flow script to obtain an access token for the account your application will access, and simply store that or hard-code it into your application.  I would recommend getting a dedicated API Key for that purpose. I created this example javascript code could easily be used to obtain an access token for this purpose. I'd be inclined to build in an ability to enter a new/udpated access token, in case you ever needed to reauthorize your application, but at this time, our access tokens have a very long lifespan.

 

I hope this is helpful.

 

Cheers,

Mark Coleman
Support Engineer

View solution in original post

Highlighted
Moderator

Re: Need authorization for single stand alone windows app

Mark's example is the best way to get an OAuth 2 token today for your purposes.  We are definitely looking at this type of scenario going forward and hopefully you'll hear more about this in the future.  We do intend to create an easy way to get an OAuth 2 token for your own account, we just aren't there today.

Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Occasional Contributor

Re: Need authorization for single stand alone windows app

Thanks for the help.  I was able to set up a page with that javascript and retrieve a token.

 

However, when i try to pull data, I get "Error 404: Not Found" as a response.  Any idea what I'm doing wrong?

 

Below is an example URL I'm hitting, with my account username and the token I received using the javascript substituted...

 

https://api.constantcontact.com/ws/customers/USER/contacts/?access_token=XXXXXXXX-XXXX-XXXX-XXXX-XXX...

Highlighted
Occasional Contributor

Re: Need authorization for single stand alone windows app

After I posted, I wondered if user might not be the same as login name for the account.  So I tried substituting the user name as shown in my posts on this forum but then I get this....

 

HTTP Status 403 - Not Allowed to access Stat

Highlighted
Moderator

Re: Need authorization for single stand alone windows app

Your URL is not correct for the resource you're trying to use, the 404 is actually the correct response I'd expect.  Here's the correct URL:

 

https://api.constantcontact.com/ws/customers/{username}/contacts?access_token=XXXXXX

 

Notice there is no / at the end of the contacts resources before the query parameters.

Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Occasional Contributor

Re: Need authorization for single stand alone windows app

Excellent!  Thank you.  Sorry for not catching that on my own.  Fat finger mistake.  Its working now.

 

 

Highlighted
Moderator

Re: Need authorization for single stand alone windows app

Never a problem, happens to us all.  Glad it was an easy catch this time and we could help you!

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured