Due to an issue with YouTube, inserting videos in your emails is showing an error. Until they are able to resolve this issue, we recommend using a different video hosting service. We will continue to monitor this outage and update you as we have more information.
I'm trying to implement the OAuth log in code for C# I know I need to pass redirect uri and API key somewhere somehow, but I'm not sure how. Can anyone post some sample code on just that part about how to get that working?
Solved! Go to Solution.
Thank you for reaching out to the API Support team here at Constant Contact.
If you are not using a 3rd-party OAuth library, I'd recommend installing our C#/.NET wrapper. The README contains instructions and a code sample on how to set up OAuth to generate an access token. You can find it at https://github.com/constantcontact/.net-sdk
Please have a look and let me know if you have any questions!
Tier II API Support Engineer
Thanks for the reply. I've sen that sample code.It uses winforms. I would need to use the webforms function to do my authentication. Do you have an example of that?
Or anyone. This is an open invitation.
Did you notice the 2.2 section for webforms? It is buried down a bit farther so it can be harder to spot. Here is a direct link and hopefully this will be helpful. https://github.com/constantcontact/.net-sdk#22-for-web-forms
Thanks. That moved me forward closer to where I want to be. I'm still experiencing an issue. In the API example the code to get the access token looks like
_accessToken = OAuth.GetAccessTokenByCodeForWebApplication(HttpContext.Current, code);
But the function I am able to call in my code looks a little different:
_accessToken = OAuth.GetAccessTokenByCode(HttpContext.Current, code);
Code is getting the value from the querystring that was returned when I chose allow. The token is still coming back as null. Am I making a mistake somewhere?
If this response is coming back as null then you are most likely not submitting something correctly. At this step in the process you should have received a code from the first step and you are now exchanging that code for an Access Token. When you exchange the code for the Access Token you are sending along several bits of data for validation. You are sending your API Key, your client secret, the code you received in the previous step, and the redirect URI. If any of these do not match then you will not get an Access Token back.
You can log in to your Mashery account to check on your API Key, client secret, and redirect URI are correct. The code comes from the previous step.
A full explanation comes from here; check the "Access Token Request" section specifically. http://developer.constantcontact.com/docs/authentication/oauth-2.0-server-flow.html
That was the answer. Thank you. If anyone else is ever confused in the way that I was, you need to add the below to the appsettings in your webconfig
<add key="APIKey" value="yourkey"/>
<add key="RedirectURL" value="yoururl"/>
<add key ="ClientSecretKey" value="yoursecret"/>