Hello,
Based on that error message, it seems like this exact method may not work best for you, as it seems that you may be working with a web application rather than a desktop/winforms application. For working with a web application, here's how I built an OAuth tester.
Default.aspx:
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<a href="?getToken=true">Get a Token!</a>
Your Token is: <asp:Label ID="tokenholder" runat="server"/>
</asp:Content>
Default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CTCT.Authentication.WebPage;
namespace WebApplication2
{
public partial class _Default : Page
{
protected string token="empty";
protected void Page_Load(object sender, EventArgs e)
{
if (HttpContext.Current.Request.QueryString["getToken"] != null)
{
var authPage = new AuthenticationWebPage(HttpContext.Current, "");
authPage.GetAuthorizationCode();
}
else if (HttpContext.Current.Request.QueryString["code"] != null)
{
var authPage = new AuthenticationWebPage(HttpContext.Current, "");
token = authPage.GetAccessTokenByCode(HttpContext.Current.Request.QueryString["code"]);
}
tokenholder.Text = token;
}
}
}
Add the following to your web.config, filling in the values:
<appSettings>
<add key="APIKey" value="YOUR_API_KEY" />
<add key="RedirectURL" value="YOUR_REDIRECT_URL" />
<add key="ClientSecretKey" value="YOUR_API_KEY_SECRET" />
</appSettings>
For the purposes of testing, you will want to configure your redirect URL to point at the default.aspx page. Please note that the Redirect URL in your config, and the redirect URL configured on your API key must match. You can edit your API key to set the Redirect URL here: https://constantcontact.mashery.com/apps/myapps
If you have any difficulty with this, please let me know!
Sincerely,
Elijah G.
API Support Engineer