cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
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?

 

 

 

3 REPLIES 3
CTCT 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

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

 

CTCT 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