2

I am having an issue with the Aweber C# api from: http://aweber.codeplex.com/

I am getting an unauthorized response from the following code. I was wondering if someone could help me see what I am missing please?

String consumerKey = "####";
String consumerSecret = "####";

API api = new API(consumerKey, consumerSecret);

api.OAuthToken = "####";
api.OAuthTokenSecret = "####";
api.OAuthVerifier = "##";

Aweber.Entity.Account account = api.getAccount();

I am assuming I am missing something important, but I cant figure out what is is.

Thanks in advance for your help.

D.

DiscoDamo
  • 59
  • 7

1 Answers1

0

You need to add following code before api.getAccount();

        // Set callback url (if not set will default to this page)
        api.CallbackUrl = "http://" + Request.Url.Host + ":" + Request.Url.Port + "/Authorize.aspx";

        // Get request token
        api.get_request_token();
        // Save the token and secret in session 
        HttpContext.Current.Session.Add("oauth_token", api.OAuthToken);
        HttpContext.Current.Session.Add("oauth_token_secret", api.OAuthTokenSecret);

        // Will redirect user to the Aweber authorize page
        api.authorize();