I can't get GetAuthorizationURL to work outside of Page Load

Nov 9, 2015 at 1:13 AM
Edited Nov 9, 2015 at 1:14 AM
Note: This is version 0.9.9.8

The GetAuthorizationURL code works when I place everything in the page load but when I break it in half so I can activate it using a button it does not work. The second half of the code (which is after the redirect from twitter authorize page) gets all the information it needs and is in the page load.

This is when it is properly working and everything is in Page Load()
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Request["oauth_token"] == null)
        {
            var appCreds = new ConsumerCredentials("consumer_key", 

"consumer_secret");

            var redirectURL = Request.Url.AbsoluteUri;
            var url = CredentialsCreator.GetAuthorizationURL(appCreds, redirectURL);

            Response.Redirect(url);
        }
        else
        {

            var verifierCode = Request.Params.Get("oauth_verifier");
            var authorizationId = Request.Params.Get("authorization_id");

            //Create the user credentials
            var userCreds = CredentialsCreator.GetCredentialsFromVerifierCode(verifierCode, authorizationId);

            Auth.ExecuteOperationWithCredentials(userCreds, () =>
            {
                Tweet.PublishTweet("Test  Tweet  1");

            });

        }
        
    }
Now when I break it into two for some odd reason it does not work. Here is the 1st portion which is in the button
    protected void Button1(object sender, EventArgs e)
    {
        if (Request["oauth_token"] == null)
        {
            var appCreds = new ConsumerCredentials("consumer_key", "consumer_secret");

            var redirectURL = Request.Url.AbsoluteUri;
            var url = CredentialsCreator.GetAuthorizationURL(appCreds, redirectURL);

            Response.Redirect(url);
        }
    }
Now here is the second part after the authorization/redirect
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["oauth_verifier"] != null)
        {
            var verifierCode = Request.Params.Get("oauth_verifier");
            var authorizationId = Request.Params.Get("authorization_id");

            //Create the user credentials
            var userCreds = CredentialsCreator.GetCredentialsFromVerifierCode(verifierCode, authorizationId);

            Auth.ExecuteOperationWithCredentials(userCreds, () =>
            {
                Tweet.PublishTweet("Test Tweet 2");
            });
        }
        
    }
I still get the verifierCode and authorizationId as normal. No error occurs it should have posted a new tweet. Everything is filled in properly. It looks like nothing is wrong. Please help as this is really odd