Пример #1
0
        void StartXauthLogin(string user, string password, NSAction callback)
        {
            LoadMoreElement status = loginDialog.Root [1][0] as LoadMoreElement;

            // Spin off a thread to start the OAuth authentication process,
            // let the GUI thread show the spinner.
            ThreadPool.QueueUserWorkItem(delegate {
                var oauth = new OAuthAuthorizer(TwitterAccount.OAuthConfig, user, password);

                if (oauth.AcquireAccessToken())
                {
                    BeginInvokeOnMainThread(delegate {
                        if (callback == null)
                        {
                            StartupAfterAuthorization(oauth);
                        }
                        else
                        {
                            SetDefaultAccount(oauth);
                            callback();
                        }
                    });
                    return;
                }

                BeginInvokeOnMainThread(delegate {
                    status.Animating = false;
                    loginAlert       = new UIAlertView(Locale.GetText("Error"),
                                                       Locale.GetText("Unable to login"),
                                                       null, null, Locale.GetText("Ok"));
                    loginAlert.Dismissed += delegate { loginAlert = null; };
                    loginAlert.Show();
                });
            });
        }
Пример #2
0
            bool LoadHook(UIWebView sender, NSUrlRequest request, UIWebViewNavigationType navType)
            {
                var requestString = request.Url.AbsoluteString;

                if (requestString.StartsWith(container.config.Callback))
                {
                    var results = HttpUtility.ParseQueryString(requestString.Substring(container.config.Callback.Length + 1));

                    container.AuthorizationToken    = results ["oauth_token"];
                    container.AuthorizationVerifier = results ["oauth_verifier"];
                    DismissModalViewControllerAnimated(false);

                    container.AcquireAccessToken();
                    callback();
                }
                return(true);
            }
Пример #3
0
        void StartXauthLogin(string user, string password, NSAction callback)
        {
            LoadMoreElement status = loginDialog.Root [1][0] as LoadMoreElement;

            // Spin off a thread to start the OAuth authentication process,
            // let the GUI thread show the spinner.
            ThreadPool.QueueUserWorkItem (delegate {
                var oauth = new OAuthAuthorizer (TwitterAccount.OAuthConfig, user, password);

                if (oauth.AcquireAccessToken ()){
                    BeginInvokeOnMainThread (delegate {
                        if (callback == null)
                            StartupAfterAuthorization (oauth);
                        else {
                            SetDefaultAccount (oauth);
                            callback ();
                        }
                    });
                    return;
                }

                BeginInvokeOnMainThread (delegate {
                    status.Animating = false;
                    loginAlert = new UIAlertView (Locale.GetText ("Error"),
                                                 Locale.GetText ("Unable to login"),
                                                 null, null, Locale.GetText ("Ok"));
                    loginAlert.Dismissed += delegate { loginAlert = null; };
                    loginAlert.Show ();
                });
            });
        }