Search code examples
c#asp.netaweber

Saving authentication Keys on AWeber API


I'm using the AWeber API from Codeplex to create a private App.

According to the documentation at http://aweber.codeplex.com/documentation, after authorizing the application I can save the api.OAuthToken and api.OAuthTokenSecret to be used on further calls.

What I do in code is:

    API api = new API(consumerKey, consumerSecret);

    api.OAuthToken = oauth_token; // Saved previously
    api.OAuthTokenSecret = oauth_token_secret;  // Saved previously

    Account account = api.getAccount();

in the call to api.getAccount() I'm getting a Remote Server: 401 Not authorized Exception.

What I'm doing wrong? How long can I store the tokens and still be valid? Do I need another call or set another field on api?

Thanks for all your responses.


Solution

  • Finally I get it working this way:

    1. Use the PHP script provided in How to create an app in Aweber?

    2. Copy the accessKey and accessSecretvariables to your C# code (these are the permanent keys).

    3. Initialize the API with this code:

    AWeber.API api = new AWeber.API(consumerKey, consumerSecret);

    api.OAuthToken = accessKey;
    
    api.OAuthTokenSecret = accessSecret;
    

    And then you can make further calls