BoxKite.Twitter.TwitterConnection.CompleteUserAuthentication C# (CSharp) Метод

CompleteUserAuthentication() публичный Метод

Second stage of PIN-based Authentication (and Authorisation) confirms the supplied PIN is correct for this user, application, session
public CompleteUserAuthentication ( string pin, string oAuthToken ) : Task
pin string PIN as entered by the user
oAuthToken string OAuth token supplied by BeginUserAuthentication
Результат Task
        public async Task<TwitterCredentials> CompleteUserAuthentication(string pin, string oAuthToken)
        {
            var twittercredentials = await UserSession.ConfirmPin(pin, oAuthToken);
            return !twittercredentials.Valid ? null : twittercredentials;
        }

Usage Example

        public static void GetTweets(string consumerKey, string consumerSecret)
        {
            ConsoleOutput.PrintMessage("Welcome to BoxKite.Twitter Console");
            ConsoleOutput.PrintMessage("(control-c ends)");
            System.Console.CancelKeyPress += cancelStreamHandler;

            TwitterCredentials twittercredentials = null;

            TwitterConnection = new TwitterConnection(consumerKey, consumerSecret);

            // PIN based authentication
            var oauth = TwitterConnection.BeginUserAuthentication().Result;

            // if the response is null, something is wrong with the initial request to OAuth
            if (!string.IsNullOrWhiteSpace(oauth))
            {
                ConsoleOutput.PrintMessage("Pin: ");
                var pin = System.Console.ReadLine();
                twittercredentials = TwitterConnection.CompleteUserAuthentication(pin, oauth).Result;

                ManageTwitterCredentials.SaveTwitterCredentialsToFile(twittercredentials);
            }
            else
            {
                ConsoleOutput.PrintError("Cannot OAuth with Twitter");
            }

            GetTweets(twittercredentials);

            ConsoleOutput.PrintMessage("All Finished");
            System.Console.ReadLine();
        }