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.

Question on OAuth in v2 with access token in C# library

SOLVED
Go to solution
Highlighted
Occasional Advisor

Question on OAuth in v2 with access token in C# library

If I just run the code and let it try to generate an access token, it fails giving:

 

CTCT.Exceptions.CtctException was unhandled
HResult=-2146233088
Message=http.status.unauthorized:No authentication is present.

Source=CTCT
StackTrace:
at CTCT.Services.ListService.GetLists(String accessToken, String apiKey) in c:\dev\projects\.net-sdk\CTCTWrapper\Services\ListService.cs:line 33
at CTCT.ConstantContact.GetLists() in c:\dev\projects\.net-sdk\CTCTWrapper\ConstantContact.cs:line 410

 

Here was the code I tried:

 

ConstantContact cc = new ConstantContact();
var lists = cc.GetLists();

 

Now, if I just create an access token on the Mashery site and create a new constructor that uses that access token, everything works fine:

 

ConstantContact cc = new ConstantContact(apiKey, accessToken);
var lists = cc.GetLists();

 

Am I supposed to be using the Mashery-generated token, or is the library supposed to be able to generate it at runtime?

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Employee

Re: Question on OAuth in v2 with access token in C# library

Hi Rich,

 

The .NET wrapper doesn't currently have the ability to generate an access token, so you would have to get that from the I/O Docs page right now.  Sorry about that.

 

Best Regards,

Shannon W.

API Support Specialist

View solution in original post

3 REPLIES 3
Highlighted
Employee

Re: Question on OAuth in v2 with access token in C# library

Hi Rich,

 

The .NET wrapper doesn't currently have the ability to generate an access token, so you would have to get that from the I/O Docs page right now.  Sorry about that.

 

Best Regards,

Shannon W.

API Support Specialist

View solution in original post

Highlighted
Occasional Advisor

Re: Question on OAuth in v2 with access token in C# library

You should probably update the code or docs then because the current constructor gives the impression that it DOES create an access token via:

 

public ConstantContact()
{
     InitializeFields();
     this.AccessToken = this.OAuth.GetAccessToken();
     this.APIKey = ConfigurationManager.AppSettings["APIKey"];
}

 

Highlighted
Employee

Re: Question on OAuth in v2 with access token in C# library

Hi Rich,

 

Thanks for the feedback.  From what I understand, that piece is still in development, but I will double back and make sure it's updated to work.

 

Best Regards,

Shannon W.

API Support Specialist

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