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.

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

SOLVED
Go to solution
EBSHealthcare
Regular Participant

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
Shannon_W
Employee

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
Shannon_W
Employee

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

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"];
}

 

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