This project has moved and is read-only. For the latest updates, please go here.

Cannot PinAuthorize PIN

Dec 22, 2014 at 3:02 AM
Edited Dec 22, 2014 at 3:08 AM
have a form with a webview , textbox for enter the pin and a button for authorise the pin. I wrote the following code but await pinAuth.CompleteAuthorizeAsync(pintextbox.Text); will give error. What is wrong?
        private async void login_Load(object sender, EventArgs e)
                string oauthToken = null;
                string oauthTokenSecret = null;

                var pinAuth = new PinAuthorizer
                    CredentialStore = new InMemoryCredentialStore
                        ConsumerKey = ConfigurationManager.AppSettings["consumerKey"],
                        ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"],
                        OAuthToken = oauthToken,
                        OAuthTokenSecret = oauthTokenSecret

                    GoToTwitterAuthorization = pageLink =>
                        webBrowser1.Navigate(new Uri(pageLink, UriKind.Absolute))

                if (oauthToken != null)

                    var credentials = pinAuth.CredentialStore;
                    string oauthTokenx = credentials.OAuthToken;
                    string oauthTokenSecretx = credentials.OAuthTokenSecret;
                    string screenName = credentials.ScreenName;
                    ulong userID = credentials.UserID;


                if (oauthToken == null)
                    await pinAuth.BeginAuthorizeAsync();


        private async void button1_Click(object sender, EventArgs e)
            await pinAuth.CompleteAuthorizeAsync(pintextbox.Text);
Dec 22, 2014 at 3:11 AM

Are you sure you want to use PIN authorization? It's mainly for applications that aren't able to handle the normal Web OAuth flow. I would use Web authorizer instead. Here's an explanation of how it works in WebForms:

The downloadable source code also contains an example in the Linq2TwitterDemos_WebForms project. Here's a link to where it is in the source code:

Marked as answer by sebyku on 12/22/2014 at 3:51 AM
Dec 22, 2014 at 2:00 PM
Thank you.