Reply
Participant
sb_sivakumar
Posts: 22
Registered: ‎12-31-2010

Is OAUTH successful with constant contact

Hi Constant Contact Team / Other friends,


For the past two days i am struggling with oauth mechanism for connecting constant contact accounts, but could not able to success in my task. i am using c# and asp.net to connect to the website. Here is my url construction, for readability i breaked the url address code


https://oauth.constantcontact.com/ws/oauth/request_token?oauth_callback=http://localhost:2364/Consta...

&oauth_consumer_key=xxxxx

&oauth_nonce=9890145

&oauth_signature_method=HMAC-SHA1

&oauth_timestamp=1297851108

&oauth_version=1.0

&oauth_signature=xxxx


I am getting the following error as mentioned below,


HTTP Status 401 - Invalid signature for signature method HMAC-SHA1


i am able to figure it out where i am going wrong while genrating the oauth_signature i am using the OAUTHBase.cs file from this link  from oauth website, the constant contact api documentation clearly states that "You should use the POST method when accessing this URL and always use SSL." After doing some research i came to know that we need add certificates along with the requests when api calls are made to 3rd party using SSL.


I am struck with the first step1 not able to proceed further, My question is whether constant contact is providing any certificates then how to get them, please let me know if any one has solved this type of problems, or whethere i am struck with some other issue.


Reference urls:


http://blog.reamped.net/post/2009/04/27/The-HttpWebRequest-and-Using-Client-Certificates.aspx


http://support.microsoft.com/kb/901183/en-us


 

CTCT Employee
David_J
Posts: 510
Registered: ‎06-04-2009

Re: Is OAUTH successful with constant contact

Hi. I would strongly recommend checking out the DevDefined OAuth Library. This library is recommended by OAuth.net and has great documentation that can likely help you with your OAuth Integration.


Step 1 of this library would appear as follows:




OAuthConsumerContext CTContext = new OAuthConsumerContext

{

     ConsumerKey = "API KEY HERE",

     ConsumerSecret = "CONSUMER SECRET HERE",

     SignatureMethod = SignatureMethod.HmacSha1

};



OAuthSession CTCTSession = new OAuthSession(CTContext,

     "https://oauth.constantcontact.com/ws/oauth/request_token",

     "https://oauth.constantcontact.com/ws/oauth/confirm_access",

     "https://oauth.constantcontact.com/ws/oauth/access_token",

     "oob");



IToken requestToken = CTCTSession.GetRequestToken();

As I've mentioned, we are looking to create an C#/ASP.NET example of this for demonstration purposes in the near future to help with this. If you have any questions please let us know. Thanks.

David J

Participant
sb_sivakumar
Posts: 22
Registered: ‎12-31-2010

Hello, I have checked the

Hello,


I have checked the above link as specfieid and was able to successfully get the unauthorized request token, but after some time the application is giving the following error.  I am using the code dll which are given in the above link.  Please let me know any chance of resolving this issue.



 


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.



Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 208.75.122.88:443



Source Error:












Line 94:
Line 95: // get a request token from the provider
Line 96: IToken requestToken = session.GetRequestToken();
Line 97:
Line 98: //Response.Write(requestToken.ToString());




Source File:c:XXXXXXXX\Default.aspx.cs    Line: 96



Stack Trace:












System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +239
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +224


DevDefined.OAuth.Consumer.ConsumerRequest.ToBodyParameters() in C:\dev\projects\devdefined-tools\projects\oauth\DevDefined.OAuth\Consumer\ConsumerRequest.cs:241
DevDefined.OAuth.Consumer.ConsumerRequest.Select(Func`2 selectFunc) in C:\dev\projects\devdefined-tools\projects\oauth\DevDefined.OAuth\Consumer\ConsumerRequest.cs:249
DevDefined.OAuth.Consumer.OAuthSession.GetRequestToken() in C:\dev\projects\devdefined-tools\projects\oauth\DevDefined.OAuth\Consumer\OAuthSession.cs:76
OAuthSample._Default.check() in C:\xxxxxxx\Default.aspx.cs:96
OAuthSample._Default.Page_Load(Object sender, EventArgs e) in C:\Users\xxxxxxx\Desktop\OAuthSample\OAuthSample\OAuthSample\Default.aspx.cs:66
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627




No connection could be made because the target machine actively refused it 208.75.122.88:443

Participant
sb_sivakumar
Posts: 22
Registered: ‎12-31-2010

Hi i have solved the

Hi i have solved the problem,


Like i have reached up to 3 rd step in this document url  as given below.


now i have oauth_token  and oauth_token_secret  keys,  see if i want to access the below url and get the all the campaings for a specific user in which i generated the keys for that account, do i still need the username and password to get the campaigns, if the username and password is still required? please let me know in this regard.


https://api.constantcontact.com/ws/customers/{user-name}/campaigns/

CTCT Employee
bsoder
Posts: 440
Registered: ‎06-05-2009

username and password with oauth

Hello,



You will no longer need the accounts password, but you will still need to get the username to make API calls.



If you have any questions let us know.



Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Participant
sb_sivakumar
Posts: 22
Registered: ‎12-31-2010

Hi Thanks for you

Hi Thanks for you reply,


Still i have some questions. when i send the requests like give below i am getting error and the details are.



2.https://api.constantcontact.com/ws/customers/{myusername}/campaigns/1104186216852



3.https://api.constantcontact.com/ws/customers/{myusername}/campaigns/1104186216852/events/opens?pageS... 



 


May i know why the second request is failing to fetch the data , i am able to fetch the data for 2nd request alos using basic authentication, basically i am lookin for summary data in the second request url. now we are moving to oauth.  Please let me know further to proceed/modify my logic.


 



1.https://api.constantcontact.com/ws/customers/{myusername}/campaigns

CTCT Employee
bsoder
Posts: 440
Registered: ‎06-05-2009

400 bad request

Hello,



I responded to this questions here: http://developer.constantcontact.com/node/2108



Please let me know if you have any question!



Regards,

Benjamin Soder
NOC Analyst
Constant Contact