protected override void OnElementChanged(ElementChangedEventArgs <Page> e)
        {
            base.OnElementChanged(e);
            var activity           = this.Context as Activity;
            var TwitterKey         = Xamarin.Forms.Application.Current.Resources["TwitterKey"].ToString();
            var TwitterSecret      = Xamarin.Forms.Application.Current.Resources["TwitterSecret"].ToString();
            var TwitterRequestURL  = Xamarin.Forms.Application.Current.Resources["TwitterRequestURL"].ToString();
            var TwitterAuthURL     = Xamarin.Forms.Application.Current.Resources["TwitterAuthURL"].ToString();
            var TwitterCallbackURL = Xamarin.Forms.Application.Current.Resources["TwitterCallbackURL"].ToString();
            var TwitterURLAccess   = Xamarin.Forms.Application.Current.Resources["TwitterURLAccess"].ToString();

            var auth = new OAuth1Authenticator(
                consumerKey: TwitterKey,
                consumerSecret: TwitterSecret,
                requestTokenUrl: new Uri(TwitterRequestURL),
                authorizeUrl: new Uri(TwitterAuthURL),
                callbackUrl: new Uri(TwitterCallbackURL),
                accessTokenUrl: new Uri(TwitterURLAccess));

            activity.StartActivity(auth.GetUI(activity));

            auth.Completed += async(sender, eventArgs) =>
            {
                if (eventArgs.IsAuthenticated)
                {
                    var profile = await GetTwitterProfileAsync(eventArgs.Account);

                    App.Navigate_ToProfile(profile, "Twitter");
                }
                else
                {
                    App.HideLoginView();
                }
            };
        }
Пример #2
0
        private void Authenticate(Xamarin.Auth.Helpers.OAuth1 oauth1)
        {
            Auth1 = new OAuth1Authenticator
                    (
                consumerKey: oauth1.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                consumerSecret: oauth1.OAuth1_SecretKey_ConsumerSecret_APISecret,
                requestTokenUrl: oauth1.OAuth1_UriRequestToken,
                authorizeUrl: oauth1.OAuth_UriAuthorization,
                accessTokenUrl: oauth1.OAuth_UriAccessToken_UriRequestToken,
                callbackUrl: oauth1.OAuth_UriCallbackAKARedirect,
                // Native UI API switch
                //      true    - NEW native UI support
                //      false   - OLD embedded browser API [DEFAULT]
                // DEFAULT will be switched to true in the near future 2017-04
                isUsingNativeUI: test_native_ui
                    )
            {
                AllowCancel = oauth1.AllowCancel,
            };

            // If authorization succeeds or is canceled, .Completed will be fired.
            Auth1.Completed         += Auth_Completed;
            Auth1.Error             += Auth_Error;
            Auth1.BrowsingCompleted += Auth_BrowsingCompleted;

            global::Android.Content.Intent ui_object = Auth1.GetUI(this);

            StartActivity(ui_object);

            return;
        }
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);
            // Instance method that will display a Twitter Sign In Page
            var auth = new OAuth1Authenticator(
                consumerKey: TwitterAuthDetails.ConsumerKey,
                consumerSecret: TwitterAuthDetails.ConsumerSecret,
                requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                callbackUrl: new Uri("https://mobile.twitter.com/home"));

            // Prevent displaying the Cancel button on the Twitter sign on page
            auth.AllowCancel = false;
            // Define our completion handler once the user has successfully signed in
            auth.Completed += (object sender, AuthenticatorCompletedEventArgs e) =>
            {
                if (e.IsAuthenticated)
                {
                    e.Account.Properties.TryGetValue("oauth_token", out oAuth_Token);
                    e.Account.Properties.TryGetValue("oauth_token_secret", out oAuth_Token_Secret);
                    // Instantiate our class to Store our Twitter Authentication Token
                    TwitterAuthDetails.StoreAuthToken(oAuth_Token);
                    TwitterAuthDetails.StoreTokenSecret(oAuth_Token_Secret);
                    TwitterAuthDetails.StoreAccountDetails(e.Account);
                }
                // Dismiss our Twitter Authentication UI Dialog
                DismissViewController(true, () =>
                {
                });
            };
            PresentViewController(auth.GetUI(), true, null);
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			var auth = new OAuth1Authenticator ("Ywun66NxYNMXgjzNRdIG12q4k",
				"XQAQ5djSlMOiXfMhn5rl4fdPahqw0wNPW6nBS5I9aRCajbxMvJ",
				new Uri("https://api.twitter.com/oauth/request_token"),
				new Uri("https://api.twitter.com/oauth/authorize"),
				new Uri("https://api.twitter.com/oauth/access_token"),
				new Uri("http://mobile.twitter.com"));

			auth.Completed += (sender, e) => {
				DismissViewController (true, null);
				if (e.IsAuthenticated) {

					loggedInAccount = e.Account;
					GetUserData ();
					var mList =   GetTwitterData();
					mList.ContinueWith(async (Task<List<Status>> arg) =>{
						myList = arg.Result;
						//twitterHomeTableView.Source = new TwitterHomeSource(arg.Result.ToArray());
					});


				}

			};

			var ui = auth.GetUI();
			PresentViewController(ui, true, null);
		}
        private void Authenticate(Xamarin.Auth.ProviderSamples.Helpers.OAuth1 oauth1)
        {
            OAuth1Authenticator auth = new OAuth1Authenticator
                                       (
                consumerKey: oauth1.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                consumerSecret: oauth1.OAuth1_SecretKey_ConsumerSecret_APISecret,
                requestTokenUrl: oauth1.OAuth1_UriRequestToken,
                authorizeUrl: oauth1.OAuth_UriAuthorization,
                accessTokenUrl: oauth1.OAuth_UriAccessToken_UriRequestToken,
                callbackUrl: oauth1.OAuth_UriCallbackAKARedirect
                                       );

            auth.AllowCancel = oauth1.AllowCancel;

            // If authorization succeeds or is canceled, .Completed will be fired.
            auth.Completed         += Auth_Completed;
            auth.Error             += Auth_Error;
            auth.BrowsingCompleted += Auth_BrowsingCompleted;

            Uri uri = auth.GetUI();

            // For Xamarin.Forms refactoring
            Microsoft.Phone.Controls.PhoneApplicationPage this_page = this;
            this.NavigationService.Navigate(uri);

            return;
        }
Пример #6
0
		public override  void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			var auth = new OAuth1Authenticator ("Ywun66NxYNMXgjzNRdIG12q4k",
				"XQAQ5djSlMOiXfMhn5rl4fdPahqw0wNPW6nBS5I9aRCajbxMvJ",
				new Uri("https://api.twitter.com/oauth/request_token"),
				new Uri("https://api.twitter.com/oauth/authorize"),
				new Uri("https://api.twitter.com/oauth/access_token"),
				new Uri("http://mobile.twitter.com"));

			auth.Completed += (sender, e) => {
				DismissViewController (true, null);
				if (e.IsAuthenticated) {

					loggedInAccount = e.Account;
					GetUserData ();
					var mList = GetTwitterData().ToString();
					PresentViewController(new TwitterTimelineTabController(mList), true, null);
				}

			};

			var ui = auth.GetUI();
			PresentViewController(ui, true, null);



		}
Пример #7
0
        private void TwitterAuth(object sender, EventArgs ee)
        {
            var auth = new OAuth1Authenticator(
                Constants.TWITTER_KEY,
                Constants.TWITTE_SECRET,
                new Uri(Constants.TWITTE_REQ_TOKEN),
                new Uri(Constants.TWITTER_AUTH),
                new Uri(Constants.TWITTER_ACCESS_TOKEN),
                new Uri(Constants.TWITTE_CALLBACKURL));

            auth.AllowCancel = true;
            StartActivity(auth.GetUI(this));

            auth.Completed += async(s, e) =>
            {
                if (!e.IsAuthenticated)
                {
                    Toast.MakeText(this, Constants.FAIL_AUTH, ToastLength.Short).Show();
                    return;
                }

                progressDialog = ProgressDialog.Show(this, Constants.WAIT, Constants.CHECKING_INFO, true);
                var request  = new OAuth1Request("GET", new Uri(Constants.TWITTER_REQUESTURL), null, e.Account);
                var response = await request.GetResponseAsync();

                if (response != null)
                {
                    progressDialog.Hide();
                    var userJson = response.GetResponseText();
                    StoringDataIntoCache(userJson);
                }
            };
        }
        private void Authenticate(Xamarin.Auth._MobileServices.Helpers.OAuth1 oauth1)
        {
            OAuth1Authenticator auth = new OAuth1Authenticator
                                       (
                consumerKey: oauth1.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                consumerSecret: oauth1.OAuth1_SecretKey_ConsumerSecret_APISecret,
                requestTokenUrl: oauth1.OAuth1_UriRequestToken,
                authorizeUrl: oauth1.OAuth_UriAuthorization,
                accessTokenUrl: oauth1.OAuth_UriAccessToken,
                callbackUrl: oauth1.OAuth_UriCallbackAKARedirect
                                       );

            auth.AllowCancel = oauth1.AllowCancel;

            // If authorization succeeds or is canceled, .Completed will be fired.
            auth.Completed         += Auth_Completed;
            auth.Error             += Auth_Error;
            auth.BrowsingCompleted += Auth_BrowsingCompleted;

            //Uri uri = auth.GetUI();
            Type page_type = auth.GetUI();

            //(System.Windows.Application.Current.RootVisual as PhoneApplicationFrame).Navigate(uri);
            this.Frame.Navigate(page_type, auth);

            return;
        }
        public async Task <SocialAccount> Login()
        {
            _oAuth1 = Helpers.SocialNetworkAuthenticators.TwitterAuth;

            SocialAccount account = null;

            _oAuth1.Completed += async(sender, args) =>
            {
                if (args.IsAuthenticated)
                {
                    account = await Helpers.SocialNetworkAuthenticators.OnCompliteTwitterAuth(args);
                }
                _isComplite = true;
            };
            _oAuth1.Error += (sender, args) => OnError?.Invoke(args.Message);

            _authUi = (Intent)_oAuth1.GetUI(MainActivity.Activity);
            MainActivity.Activity.StartActivityForResult(_authUi, -1);

            return(await Task.Run(() =>
            {
                while (!_isComplite)
                {
                    Task.Delay(100);
                }

                _authUi.Dispose();

                return account;
            }));
        }
Пример #10
0
        public LoginTwitterPageRenderer()
        {
            var activity = this.Context as Activity;

            var authTwitter = new OAuth1Authenticator(
                consumerKey: "pHX7RNbyU0qySDfM3XGVXAo5Z",
                consumerSecret: "s2k3jVdbVMGBEUEVsvJ1Hzgc0K7RpkUoabESrob5VNDECJy2zj",
                requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                callbackUrl: new Uri("http://www.devenvexe.com"));

            authTwitter.Completed += async(sender, eventArgs) =>
            {
                if (eventArgs.IsAuthenticated)
                {
                    var accessToken = eventArgs.Account.Properties["access_token"].ToString();
                    var profile     = await GetTwitterProfileAsync(accessToken);

                    await App.NavigateToProfile(profile);
                }
                else
                {
                    App.HideLoginView();
                }
            };

            activity.StartActivity(authTwitter.GetUI(activity));
        }
        private void Authenticate(Xamarin.Auth._MobileServices.Helpers.OAuth1 oauth1)
        {
            OAuth1Authenticator auth = new OAuth1Authenticator
                                       (
                consumerKey: oauth1.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                consumerSecret: oauth1.OAuth1_SecretKey_ConsumerSecret_APISecret,
                requestTokenUrl: oauth1.OAuth1_UriRequestToken,
                authorizeUrl: oauth1.OAuth_UriAuthorization,
                accessTokenUrl: oauth1.OAuth_UriAccessToken_UriRequestToken,
                callbackUrl: oauth1.OAuth_UriCallbackAKARedirect
                                       );

            auth.AllowCancel = oauth1.AllowCancel;

            // If authorization succeeds or is canceled, .Completed will be fired.
            auth.Completed         += Auth_Completed;
            auth.Error             += Auth_Error;
            auth.BrowsingCompleted += Auth_BrowsingCompleted;

            //Uri uri = auth.GetUI();
            Type page_type = auth.GetUI();

            // For Xamarin.Forms refactoring
            Windows.UI.Xaml.Controls.Page this_page = this;
            this_page.Frame.Navigate(page_type, auth);

            return;
        }
Пример #12
0
        public void Show(OAuth1Authenticator auth)
        {
            var ui     = auth.GetUI(Forms.Context);
            var intent = ui as Intent;

            if (intent != null)
            {
                Forms.Context.StartActivity(intent);
            }
        }
Пример #13
0
        partial void UIButton41_TouchUpInside(UIButton sender)
        {
            // http://dev.twitter.com/apps
            var auth = new OAuth1Authenticator(
                consumerKey: "wls4oNSNjtUTaEhzJs825g", 
 consumerSecret: "cawXz62nwLygGLCEQO1WeK6L2BbKIjI1pwxrRA9LRY", 
 requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"), 
 authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"), 
 accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"), 
 callbackUrl: new Uri("http://mobile.twitter.com"));

            var ui = auth.GetUI();

            auth.Completed += TwitterAuth_Completed;

            PresentViewController(ui, true, null);
        }
Пример #14
0
        protected override void OnElementChanged(ElementChangedEventArgs <Page> e)
        {
            base.OnElementChanged(e);

            // this is a ViewGroup - so should be able to load an AXML file and FindView<>
            var activity = this.Context as Activity;

            if (showLogin && App.User == null)
            {
                showLogin = false;

                //Twitter with oauth1
                var auth = new OAuth1Authenticator(
                    consumerKey: "6S9pEMHSbVGswU08RqacNSTMT",
                    consumerSecret: "GMYueo1qseedj4VJWGIdwL66jh4tIcCy4JLfKlhW7CIYtRKJ0T",
                    requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),              // the redirect URL for the service
                    authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),                     // the auth URL for the service
                    accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                    callbackUrl: new Uri("https://mobile.twitter.com/home")
                    );

                auth.Completed += (sender, eventArgs) =>
                {
                    // DismissViewController(true, null);

                    if (eventArgs.IsAuthenticated)
                    {
                        App.User = new Entities.UserDetails();
                        // Use eventArgs.Account to do wonderful things
                        App.User.Token       = eventArgs.Account.Properties["oauth_token"];
                        App.User.TokenSecret = eventArgs.Account.Properties["oauth_token_secret"];
                        App.User.TwitterId   = eventArgs.Account.Properties["user_id"];
                        App.User.ScreenName  = eventArgs.Account.Properties["screen_name"];

                        //Store details for future use,
                        //so we don't have to promt authentication screen everytime
                        AccountStore.Create().Save(eventArgs.Account, "Twitter");

                        // Xamarin.Essentials.SecureStorage.

                        App.SuccessfulLoginAction.Invoke();
                    }
                    //else
                    //{
                    //    // The user cancelled
                    //}
                };

                // PresentViewController(auth.GetUI(), true, null);
                activity.StartActivity(auth.GetUI(activity));
            }
        }
Пример #15
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (showLogin && App.User == null)
            {
                //Twitter with OAuth1
                var auth = new OAuth1Authenticator(
                    consumerKey: "Add your consumer key from Twitter",
                    consumerSecret: "Add your consumer secrete from Twitter",
                    requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                    authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                    accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                    callbackUrl: new Uri("http://twitter.com")
                    );

                auth.Completed += (sender, eventArgs) =>
                {
                    DismissViewController(true, null);

                    if (eventArgs.IsAuthenticated)
                    {
                        // success
                        var account = eventArgs.Account;
                        Debug.WriteLine("--------------------");
                        Debug.WriteLine("account = " + account);
                        Debug.WriteLine("account.Username = "******"oauth_token"];
                        App.User.TokenSecret = eventArgs.Account.Properties["oauth_token_secret"];
                        App.User.TwitterId   = eventArgs.Account.Properties["user_id"];
                        App.User.Name        = eventArgs.Account.Properties["screen_name"];
                        Debug.WriteLine("--------------------");
                        Debug.WriteLine("App.User.Token = " + App.User.Token);
                        Debug.WriteLine("App.User.TokenSecret = " + App.User.TokenSecret);
                        Debug.WriteLine("App.User.TwitterId = " + App.User.TwitterId);
                        Debug.WriteLine("App.User.Name = " + App.User.Name);

                        //Store details for future use,
                        //so we don't have to prompt authentication screen everytime
                        AccountStore.Create().Save(eventArgs.Account, "Twitter");

                        App.SuccessfulLoginAction.Invoke();
                    }
                };

                PresentViewController(auth.GetUI(), true, null);
            }
        }
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (showLogin && App.User == null)
            {
                showLogin = false;

                //Twitter with oauth1
                var auth = new OAuth1Authenticator(
                    consumerKey: "Twitter Consumer Key",
                    consumerSecret: "Twitter Consumer Secret",
                    // the redirect URL for the service
                    requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                    // the auth URL for the service
                    authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                    accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                    // callback url must be to a page where the URL does not change during navigation
                    callbackUrl: new Uri("https://mobile.twitter.com")
                    );

                auth.Completed += async(sender, eventArgs) =>
                {
                    // DismissViewController(true, null);
                    await Element.Navigation.PopModalAsync();

                    if (eventArgs.IsAuthenticated)
                    {
                        App.User = new Entities.UserDetails();
                        // Use eventArgs.Account to do wonderful things
                        App.User.Token       = eventArgs.Account.Properties["oauth_token"];
                        App.User.TokenSecret = eventArgs.Account.Properties["oauth_token_secret"];
                        App.User.TwitterId   = eventArgs.Account.Properties["user_id"];
                        App.User.ScreenName  = eventArgs.Account.Properties["screen_name"];

                        //Store details for future use,
                        //so we don't have to promt authentication screen everytime
                        AccountStore.Create().Save(eventArgs.Account, "Twitter");

                        App.SuccessfulLoginAction.Invoke();
                    }
                    //else
                    //{
                    //    // The user cancelled
                    //}
                };

                PresentViewController(auth.GetUI(), true, null);
            }
        }
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (showLogin && App.User == null)
            {
                showLogin = false;

                //Twitter with oauth1
                var auth = new OAuth1Authenticator(
                    consumerKey: "Twitter Consumer Key",
                    consumerSecret: "Twitter Consumer Secret",
                    // the redirect URL for the service
                    requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                    // the auth URL for the service
                    authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                    accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                    // callback url must be to a page where the URL does not change during navigation
                    callbackUrl: new Uri("https://mobile.twitter.com")
                );

                auth.Completed += async (sender, eventArgs) =>
                {
                    // DismissViewController(true, null);
                    await Element.Navigation.PopModalAsync();

                    if (eventArgs.IsAuthenticated)
                    {
                        App.User = new Entities.UserDetails();
                        // Use eventArgs.Account to do wonderful things
                        App.User.Token = eventArgs.Account.Properties["oauth_token"];
                        App.User.TokenSecret = eventArgs.Account.Properties["oauth_token_secret"];
                        App.User.TwitterId = eventArgs.Account.Properties["user_id"];
                        App.User.ScreenName = eventArgs.Account.Properties["screen_name"];

                        //Store details for future use,
                        //so we don't have to promt authentication screen everytime
                        AccountStore.Create().Save(eventArgs.Account, "Twitter");

                        App.SuccessfulLoginAction.Invoke();
                    }
                    //else
                    //{
                    //    // The user cancelled
                    //}
                };

                PresentViewController(auth.GetUI(), true, null);
            }
        }
Пример #18
0
        //Login with Twitter
        private void LoginToTwitter()
        {
            var auth = new OAuth1Authenticator(
                Constants.CustomerKey,
                Constants.CustomerSecret,
                new Uri("https://api.twitter.com/oauth/request_token"),
                new Uri("https://api.twitter.com/oauth/authorize"),
                new Uri("https://api.twitter.com/oauth/access_token"),
                new Uri("http://mobile.twitter.com")

                );

            auth.Completed += twitter_auth_Completed;
            StartActivity(auth.GetUI(this));
        }
Пример #19
0
        public void AuthorizeTwitter(Action<AGCAuthCredential> AuthorizationCompleted)
        {
            this.authorizationCompleted = AuthorizationCompleted;
            var auth = new OAuth1Authenticator(
                    consumerKey: "CONSUMER_KEY",
                    consumerSecret: "CONSUMER_SECRET",
                    requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                    authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                    accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                    callbackUrl: new Uri("http://mobile.twitter.com/home"));

            var ui = auth.GetUI();
            auth.Completed += TwitterAuth_Completed;
            parent.PresentViewController(ui, true, null);
        }
Пример #20
0
        private void ImgTwitter_Click(object sender, EventArgs e)
        {
            var auth = new OAuth1Authenticator(
                consumerKey: "enteryourappkey",                                          // For Twitter login, for configure refer http://www.c-sharpcorner.com/article/register-identity-provider-for-new-oauth-application/
                consumerSecret: "enteryoursecreykey",                                    // For Twitter login, for configure refer http://www.c-sharpcorner.com/article/register-identity-provider-for-new-oauth-application/
                requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"), // These values do not need changing
                authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),        // These values do not need changing
                accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),   // These values do not need changing
                callbackUrl: new Uri("http://mobile.twitter.com/home")                   // Set this property to the location the user will be redirected too after successfully authenticating
                );

            auth.AllowCancel = true;
            auth.Completed  += Auth_Completed;

            StartActivity(auth.GetUI(this));
        }
        protected override void OnElementPropertyChanged(object s, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(s, e);

            var activity = this.Context as Activity;

            if (showLogin && App.User == null)
            {
                showLogin = false;

                //Twitter with oauth1
                var auth = new OAuth1Authenticator(
                    consumerKey: "Twitter Consumer Key",
                    consumerSecret: "Twitter Consumer Secret",
                    // the redirect URL for the service
                    requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                    // the auth URL for the service
                    authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                    accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                    // callback url must be to a page where the URL does not change during navigation
                    callbackUrl: new Uri("https://mobile.twitter.com")
                    );

                auth.Completed += async(sender, eventArgs) =>
                {
                    await Element.Navigation.PopModalAsync();

                    if (eventArgs.IsAuthenticated)
                    {
                        App.User = new Entities.UserDetails();
                        // Use eventArgs.Account to do wonderful things
                        App.User.Token       = eventArgs.Account.Properties["oauth_token"];
                        App.User.TokenSecret = eventArgs.Account.Properties["oauth_token_secret"];
                        App.User.TwitterId   = eventArgs.Account.Properties["user_id"];
                        App.User.ScreenName  = eventArgs.Account.Properties["screen_name"];

                        App.SuccessfulLoginAction.Invoke();
                    }
                    //else
                    //{
                    //    // The user cancelled
                    //}
                };

                activity.StartActivity(auth.GetUI(activity));
            }
        }
        protected override void OnElementPropertyChanged(object s, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(s, e);

            var activity = this.Context as Activity;

            if (showLogin && App.User == null)
            {
                showLogin = false;

                //Twitter with oauth1
                var auth = new OAuth1Authenticator(
                    consumerKey: "Twitter Consumer Key",
                    consumerSecret: "Twitter Consumer Secret",
                    // the redirect URL for the service
                    requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                    // the auth URL for the service
                    authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                    accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                    // callback url must be to a page where the URL does not change during navigation
                    callbackUrl: new Uri("https://mobile.twitter.com")
                );

                auth.Completed += async (sender, eventArgs) =>
                {
                    await Element.Navigation.PopModalAsync();

                    if (eventArgs.IsAuthenticated)
                    {
                        App.User = new Entities.UserDetails();
                        // Use eventArgs.Account to do wonderful things
                        App.User.Token = eventArgs.Account.Properties["oauth_token"];
                        App.User.TokenSecret = eventArgs.Account.Properties["oauth_token_secret"];
                        App.User.TwitterId = eventArgs.Account.Properties["user_id"];
                        App.User.ScreenName = eventArgs.Account.Properties["screen_name"];

                        App.SuccessfulLoginAction.Invoke();
                    }
                    //else
                    //{
                    //    // The user cancelled
                    //}
                };

                activity.StartActivity(auth.GetUI(activity));
            }
        }
Пример #23
0
        partial void UIButton17067_TouchUpInside(UIButton sender)
        {
            var auth = new OAuth1Authenticator(

                consumerKey: "Iyn7ZJDVUpokTSPQDD6l2qkhq",
                consumerSecret: "0kc6KQrXzdjyfnjno2ubBct3exc8loYJs6wgwHkf46ntx74TE9",
                requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                callbackUrl: new Uri("http://www.website.com"));


            var ui = auth.GetUI();

            auth.Completed += TwitterAuth_Completed;
            PresentViewController(ui, true, null);
        }
Пример #24
0
        protected override void OnElementPropertyChanged(object s, System.ComponentModel.PropertyChangedEventArgs e)
        {
            c++;
            base.OnElementPropertyChanged(s, e);

            var auth = new  OAuth1Authenticator(
                consumerKey: App.Instance.TwitterOAuthSettings.Key,
                consumerSecret: App.Instance.TwitterOAuthSettings.Secret,
                requestTokenUrl: new Uri(App.Instance.TwitterOAuthSettings.RequestTokenUrl),
                authorizeUrl: new Uri(App.Instance.TwitterOAuthSettings.AuthorizeUrl),
                callbackUrl: new Uri(App.Instance.TwitterOAuthSettings.CallbackUrl),
                accessTokenUrl: new Uri(App.Instance.TwitterOAuthSettings.AccessUrl)
                );

            auth.Title       = "Twitter login";
            auth.AllowCancel = true;

            var activity = this.Context as Activity;

            if (c < 2)
            {
                activity.StartActivity(auth.GetUI(activity));
            }
            auth.Completed += async(sender, eventArgs) =>
            {
                if (eventArgs.IsAuthenticated)
                {
                    loggedInAccount = eventArgs.Account;
                    string idSocial   = loggedInAccount.Properties["user_id"];
                    string screenName = loggedInAccount.Properties["screen_name"];

                    await GetTwitterData(idSocial, screenName);

                    AccountStore.Create(activity).Save(loggedInAccount, "Twitter");
                    App.Instance.SuccessfulLoginAction.Invoke();
                    App.Instance.SaveToken(loggedInAccount.Properties["oauth_token"], eventArgs.Account.Properties["oauth_token_secret"]);

                    await App.Instance.IniciarSesion();
                }
                else
                {
                    // The user cancelled
                    App.Instance.SuccessfulLoginAction.Invoke();
                }
            };
        }
Пример #25
0
        private void TwitterAuth(object sender, EventArgs ee)
        {
            OAuth1Authenticator auth = new OAuth1Authenticator(
                Constants.TWITTER_KEY,
                Constants.TWITTE_SECRET,
                new Uri(Constants.TWITTE_REQ_TOKEN),
                new Uri(Constants.TWITTER_AUTH),
                new Uri(Constants.TWITTER_ACCESS_TOKEN),
                new Uri(Constants.TWITTE_CALLBACKURL))
            {
                AllowCancel = true
            };

            StartActivity(auth.GetUI(this));

            auth.Completed += Auth_Completed;
        }
Пример #26
0
        public void TwitterAuth_TouchUpInside(UIButton sender)
        {
            // http://dev.twitter.com/apps
            var auth = new OAuth1Authenticator(
                consumerKey: twitterConsumerKey,
                consumerSecret: twitterSecret,
                requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                callbackUrl: new Uri("http://mobile.twitter.com"));

            var ui = auth.GetUI();

            auth.Completed += TwitterAuth_Completed;

            PresentViewController(ui, true, null);
        }
Пример #27
0
#pragma warning restore 649
        #endregion

        private void LoginTwitter(bool allowCancel = true)
        {
            var auth = new OAuth1Authenticator(
                consumerKey: GetString(Resource.String.TwitterConsumerKey),
                consumerSecret: GetString(Resource.String.TwitterConsumerSecret),
                requestTokenUrl: new Uri(GetString(Resource.String.TwitterRequestTokenUrl)),
                authorizeUrl: new Uri(GetString(Resource.String.TwitterAuthorizeUrl)),
                accessTokenUrl: new Uri(GetString(Resource.String.TwitterAccessTokenUrl)),
                callbackUrl: new Uri(GetString(Resource.String.TwitterCallbackUrl))
                )
            {
                AllowCancel = allowCancel
            };

            auth.Completed += TwitterAuthComplete;

            StartActivity(auth.GetUI(this));
        }
Пример #28
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (done)
            {
                return;
            }

            var TwitterKey         = Xamarin.Forms.Application.Current.Resources["TwitterKey"].ToString();
            var TwitterSecret      = Xamarin.Forms.Application.Current.Resources["TwitterSecret"].ToString();
            var TwitterRequestURL  = Xamarin.Forms.Application.Current.Resources["TwitterRequestURL"].ToString();
            var TwitterAuthURL     = Xamarin.Forms.Application.Current.Resources["TwitterAuthURL"].ToString();
            var TwitterCallbackURL = Xamarin.Forms.Application.Current.Resources["TwitterCallbackURL"].ToString();
            var TwitterURLAccess   = Xamarin.Forms.Application.Current.Resources["TwitterURLAccess"].ToString();

            var auth = new OAuth1Authenticator(
                consumerKey: TwitterKey,
                consumerSecret: TwitterSecret,
                requestTokenUrl: new Uri(TwitterRequestURL),
                authorizeUrl: new Uri(TwitterAuthURL),
                callbackUrl: new Uri(TwitterCallbackURL),
                accessTokenUrl: new Uri(TwitterURLAccess));

            auth.Completed += async(sender, eventArgs) =>
            {
                DismissViewController(true, null);
                App.HideLoginView();

                if (eventArgs.IsAuthenticated)
                {
                    var profile = await GetTwitterProfileAsync(eventArgs.Account);

                    App.Navigate_ToProfile(profile, "twitter");
                }
                else
                {
                    App.HideLoginView();
                }
            };

            done = true;
            PresentViewController(auth.GetUI(), true, null);
        }
Пример #29
0
        void TwiterButton_Click(object sender, System.EventArgs e)
        {
            var auth = new OAuth1Authenticator(
                consumerKey: "XJVrM50CAFG6BClyvKnFGut3u",
                consumerSecret: "bAqZ2jskVoRRbwiamq4LqdgO0dQk1qIsCJ9KCxzpbDVzi0L0OI",
                requestTokenUrl: new System.Uri("https://api.twitter.com/oauth/request_token"),
                authorizeUrl: new System.Uri("https://api.twitter.com/oauth/authorize"),
                accessTokenUrl: new System.Uri("https://api.twitter.com/oauth/access_token"),
                callbackUrl: new System.Uri("http://mobile.twitter.com"));

            {
            };


            auth.Completed += TwitterAuth_CompletedAsync;
            var ui = auth.GetUI(this);

            StartActivity(ui);
        }
Пример #30
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (showLogin && App.User == null)
            {
                showLogin = false;

                // Twitter with OAuth1
                var auth = new OAuth1Authenticator(
                    consumerKey: "6S9pEMHSbVGswU08RqacNSTMT",
                    consumerSecret: "GMYueo1qseedj4VJWGIdwL66jh4tIcCy4JLfKlhW7CIYtRKJ0T",
                    requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"), // redirect URL for service;
                    authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),        // auth URL for service;
                    accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                    callbackUrl: new Uri("https://mobile.twitter.com/home")
                    );

                var ui = auth.GetUI();

                auth.Completed += (sender, eventArgs) =>
                {
                    DismissViewController(true, null);

                    if (eventArgs.IsAuthenticated)
                    {
                        App.User = new Entities.UserDetails();

                        App.User.Token       = eventArgs.Account.Properties["oauth_token"];
                        App.User.TokenSecret = eventArgs.Account.Properties["oauth_token_secret"];
                        App.User.TwitterId   = eventArgs.Account.Properties["user_id"];
                        App.User.ScreenName  = eventArgs.Account.Properties["screen_name"];

                        // store details for future use;
                        AccountStore.Create().Save(eventArgs.Account, "Twitter");

                        App.SuccessfulLoginAction.Invoke();
                    }
                };

                PresentViewController(ui, true, null);
            }
        }
Пример #31
0
        private void Authenticate(Xamarin.Auth.ProviderSamples.Helpers.OAuth1 oauth1)
        {
            // Step 1.1 Creating and configuring an Authenticator
            Auth1 = new OAuth1Authenticator
                    (
                consumerKey: oauth1.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                consumerSecret: oauth1.OAuth1_SecretKey_ConsumerSecret_APISecret,
                requestTokenUrl: oauth1.OAuth1_UriRequestToken,
                authorizeUrl: oauth1.OAuth_UriAuthorization,
                accessTokenUrl: oauth1.OAuth_UriAccessToken_UriRequestToken,
                callbackUrl: oauth1.OAuth_UriCallbackAKARedirect,
                // Native UI API switch
                //      true    - NEW native UI support
                //      false   - OLD embedded browser API [DEFAULT]
                // DEFAULT will be switched to true in the near future 2017-04
                isUsingNativeUI: test_native_ui
                    )
            {
                AllowCancel = oauth1.AllowCancel,
            };

            // Step 1.2 Subscribing to Authenticator events
            // If authorization succeeds or is canceled, .Completed will be fired.
            Auth1.Completed         += Auth_Completed;
            Auth1.Error             += Auth_Error;
            Auth1.BrowsingCompleted += Auth_BrowsingCompleted;

            // Step 2.1 Creating Login UI
            global::Android.Content.Intent ui_object = Auth1.GetUI(this);

            if (Auth2.IsUsingNativeUI == true)
            {
                // Step 2.2 Customizing the UI - Native UI [OPTIONAL]
                // In order to access CustomTabs API
                InitializeNativeUICustomTabs();
            }

            // Step 3 Present/Launch the Login UI
            StartActivity(ui_object);

            return;
        }
Пример #32
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (showLogin && App.User == null)
            {
                showLogin = false;

                var auth = new OAuth1Authenticator(
                    consumerKey: "IPDotz1tp4c07AZywLUbUOBza",
                    consumerSecret: "FiGWZSvk1TIlK7XMYTpmacToPBNp8F32j4cT2RYsXRwaMe5q9S",
                    requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                    authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                    accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                    callbackUrl: new Uri("https://www.facebook.com/connect/login_success.html")
                    );

                auth.Completed += (sender, eventArgs) =>
                {
                    DismissViewController(true, null);

                    if (eventArgs.IsAuthenticated)
                    {
                        App.User = new Model.UserDetails();

                        App.User.Token       = eventArgs.Account.Properties["oauth_token"];
                        App.User.TokenSecret = eventArgs.Account.Properties["oauth_token_secret"];
                        App.User.TwitterId   = eventArgs.Account.Properties["user_id"];
                        App.User.ScreenName  = eventArgs.Account.Properties["screen_name"];

                        AccountStore.Create().Save(eventArgs.Account, "Twitter");

                        App.SuccessfulLoginAction.Invoke();
                    }
                    else
                    {
                    }
                };

                PresentViewController(auth.GetUI(), true, null);
            }
        }
Пример #33
0
        public Task <FacebookLoginResult> Login()
        {
            var result = new TaskCompletionSource <FacebookLoginResult>();
            var auth   = new OAuth1Authenticator(
                "wDDuNu2auh21NLhWQu2zOdhSc",
                "QYeJH178DVJB6hSovnbWoTueHKo87WGNAPNLMmCkfcNctlaHEw",
                new Uri("https://api.twitter.com/oauth/request_token"),
                new Uri("https://api.twitter.com/oauth/authorize"),
                new Uri("https://api.twitter.com/oauth/access_token"),
                new Uri("http://mobile.twitter.com/home")
                )
            {
                AllowCancel = true
            };

            auth.Completed += async(s, eventArgs) =>
            {
                UIApplication.SharedApplication.KeyWindow.RootViewController.DismissViewController(true, null);

                var twitterLoginResult = new FacebookLoginResult();
                if (eventArgs.IsAuthenticated)
                {
                    var loggedInAccount = eventArgs.Account;
                    twitterLoginResult = new FacebookLoginResult
                    {
                        Name        = loggedInAccount.Properties["screen_name"],
                        AccessToken = loggedInAccount.Properties["oauth_token"],
                        UserId      = loggedInAccount.Properties["user_id"]
                    };

                    twitterLoginResult.Email = await GetTwitterUserMail(loggedInAccount);
                }

                twitterLoginResult.IsLoggedIn = eventArgs.IsAuthenticated;
                result.SetResult(twitterLoginResult);
            };

            UIApplication.SharedApplication.KeyWindow.RootViewController
            .PresentViewController(auth.GetUI(), true, null);

            return(result.Task);
        }
Пример #34
0
        public Task <FacebookLoginResult> Login()
        {
            var result = new TaskCompletionSource <FacebookLoginResult>();
            var auth   = new OAuth1Authenticator(
                "wDDuNu2auh21NLhWQu2zOdhSc",
                "QYeJH178DVJB6hSovnbWoTueHKo87WGNAPNLMmCkfcNctlaHEw",
                new Uri("https://api.twitter.com/oauth/request_token"),
                new Uri("https://api.twitter.com/oauth/authorize"),
                new Uri("https://api.twitter.com/oauth/access_token"),
                new Uri("http://mobile.twitter.com")
                )
            {
                AllowCancel = true
            };

            var context = Forms.Context;
            var intent  = auth.GetUI(context);

            context.StartActivity(intent);

            auth.Completed += async(s, eventArgs) =>
            {
                var twitterLoginResult = new FacebookLoginResult();
                if (eventArgs.IsAuthenticated)
                {
                    var loggedInAccount = eventArgs.Account;
                    twitterLoginResult = new FacebookLoginResult
                    {
                        Name        = loggedInAccount.Properties["screen_name"],
                        AccessToken = loggedInAccount.Properties["oauth_token"],
                        UserId      = loggedInAccount.Properties["user_id"]
                    };

                    twitterLoginResult.Email = await GetTwitterUserMail(loggedInAccount);
                }

                twitterLoginResult.IsLoggedIn = eventArgs.IsAuthenticated;
                result.SetResult(twitterLoginResult);
            };

            return(result.Task);
        }
Пример #35
0
		public override  void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			this.NavigationItem.Title = "Home";
			var auth = new OAuth1Authenticator ("Ywun66NxYNMXgjzNRdIG12q4k",
				"XQAQ5djSlMOiXfMhn5rl4fdPahqw0wNPW6nBS5I9aRCajbxMvJ",
				new Uri("https://api.twitter.com/oauth/request_token"),
				new Uri("https://api.twitter.com/oauth/authorize"),
				new Uri("https://api.twitter.com/oauth/access_token"),
				new Uri("http://mobile.twitter.com"));

			auth.Completed += (sender, e) => {
				DismissViewController (true, null);
				if (e.IsAuthenticated) {
					

					loggedInAccount = e.Account;
					GetUserData ();
					var mList =   GetTwitterData();

					TableView.RowHeight = UITableView.AutomaticDimension;
					TableView.EstimatedRowHeight = 160;

					TableView.Source = new TwitterHomeSource(mList.ToArray());
					//twitterHomeTableView.ReloadData();




				}

			};

			var ui = auth.GetUI();
			PresentViewController(ui, true, null);



		}
Пример #36
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (showLogin && App.UserInfo == null)
            {
                //Twitter with OAuth1
                var auth = new OAuth1Authenticator(
                    consumerKey: "rsrleZR4jRNIN0Cm7uPGxOpWy",
                    consumerSecret: "ij1N7CcRwPtbe76RFdon8ruCJEMNVFJ4n03AKbVDMjzAFqbPqs",
                    requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                    authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                    accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                    callbackUrl: new Uri("http://mobile.twitter.com")
                );

                auth.Completed += (sender, eventArgs) =>
                {
                    DismissViewController(true, null);

                    if (eventArgs.IsAuthenticated)
                    {
                        App.UserInfo = new User();
                        App.UserInfo.Token = eventArgs.Account.Properties["oauth_token"];
                        App.UserInfo.TokenSecret = eventArgs.Account.Properties["oauth_token_secret"];
                        App.UserInfo.TwitterId = eventArgs.Account.Properties["user_id"];
                        App.UserInfo.Name = eventArgs.Account.Properties["screen_name"];

                        //Store details for future use,
                        //so we don't have to prompt authentication screen everytime
                        AccountStore.Create().Save(eventArgs.Account, "Twitter");

                        App.SuccessfulLoginAction.Invoke();
                    }
                };

                PresentViewController(auth.GetUI(), true, null);
            }
        }
Пример #37
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear (animated);

            if (App.IsLoggedIn)
                return;

            var auth = new OAuth1Authenticator(
                consumerKey: App.Constants.consumerKey,
                consumerSecret: App.Constants.consumerSecret,
                requestTokenUrl: App.Constants.requestTokenUrl(),
                authorizeUrl: App.Constants.authorizeUrl(),
                accessTokenUrl: App.Constants.accessTokenUrl(),
                callbackUrl: App.Constants.callbackUrl()
            );
            auth.Title = "Login with Twitter";
            auth.BrowsingCompleted += (sender, e) => {
                Console.WriteLine("browsing completed");
            };
            auth.Error += (sender, e) => {
                Console.WriteLine("There was an error {0}",e.Message);
            };
            auth.Completed += (sender, e) => {
                Console.WriteLine ("Inside completed");
                DismissViewController(true, null);

                if (e.IsAuthenticated) {
                    App.User = new TwitterUser();
                    var properties = e.Account.Properties;
                    App.User.Token = e.Account.Properties["oauth_token"];
                    App.User.TokenSecret = e.Account.Properties["oauth_token_secret"];
                    App.User.TwitterId = e.Account.Properties["user_id"];
                    App.User.Name = e.Account.Properties["screen_name"];

                    App.SuccessfulLoginAction.Invoke();
                }
            };
            PresentViewController (auth.GetUI (), true, null);
        }
Пример #38
0
        private void TwitterLoginPost(string clientID, string secrete, string message, string link)
        {
            var auth = new OAuth1Authenticator(
                           consumerKey: clientID,
                           consumerSecret: secrete,
                           requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                           authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                           accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                           callbackUrl: new Uri("https://www.facebook.com/connect/login_success.html")
                       );

            auth.Completed += (sender, eventArgs) =>
            {
                if (eventArgs.IsAuthenticated)
                {
                    //save the account
                    AccountStore.Create().Save(eventArgs.Account, "Twitter");
                    //post the message
                    TwitterPost(eventArgs.Account, message, clientID, secrete, link);
                }
                else
                {
                    // The user cancelled during authentication.
                    c_ViewController.DismissViewController(true, null);

                }
            };
            auth_ViewController = auth.GetUI ();
            c_ViewController.PresentViewController(auth_ViewController , true, null);
        }
Пример #39
0
		private async Task<DataIUser> LoginToTwitter()
		{
			DataIUser resultUser = null;
			LinqToTwitter.User twitterUser = null;
			try
			{
				TaskCompletionSource<int> ts = new TaskCompletionSource<int>();

				var auth = new OAuth1Authenticator(
										consumerKey: "YVgafJLg6figpxcFTx9oBhXDw",
										consumerSecret: "AdNdiuHSHIf5hN6HWnVrC9u6bnW3vVirjEhAFrfabacPIQdh98",
					requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
					//https://api.twitter.com/oauth/authorize
					authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
					accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
					callbackUrl: new Uri("https://oauth.vk.com/blank.html"));

				auth.AllowCancel = true;

				auth.Completed += (s, ee) =>
				{
					if (!ee.IsAuthenticated)
					{
						ts.SetResult(0);
						return;
					}

					var twitterCtx = GetTwitterContext();

					var accounts =
						from acct in twitterCtx.Account
						where acct.Type == AccountType.VerifyCredentials
						select acct;

					LinqToTwitter.Account account = accounts.SingleOrDefault();

					twitterUser = account.User;

					#region unused requests

					//var searchResponses = (from search in ctx.Search
					//											 where search.Type == SearchType.Search
					//											 && search.Query == searchText
					//											 select search).SingleOrDefault();

					//var tweets = from tweet in searchResponses.Statuses
					//						 select new Message
					//						 {
					//							 Value = tweet.Text,
					//							 Id = tweet.TweetIDs,
					//							 ImageUri = tweet.User.ProfileImageUrl,
					//							 UserName = tweet.User.ScreenNameResponse,
					//							 Name = tweet.User.Name,
					//							 CreatedAt = tweet.CreatedAt,
					//							 ReTweets = tweet.RetweetCount,
					//							 Favorite = tweet.FavoriteCount.Value
					//						 };

					//var followers = (from follower in twitterCtx.Friendship
					//								 where follower.Type == FriendshipType.FollowersList &&
					//											 follower.UserID == "3620214675"
					//								 select follower).SingleOrDefault();

					#endregion

					string uid = twitterUser.UserIDResponse;
					string firstName = twitterUser.ScreenNameResponse;

					TwitterData.TwitterUser twUser = new TwitterData.TwitterUser();
					twUser.ConsumerKey = twitterCtx.Authorizer.CredentialStore.ConsumerKey;
					twUser.ConsumerSecret = twitterCtx.Authorizer.CredentialStore.ConsumerSecret;
					twUser.OAuthToken = twitterCtx.Authorizer.CredentialStore.OAuthToken;
					twUser.OAuthTokenSecret = twitterCtx.Authorizer.CredentialStore.OAuthTokenSecret;

					twUser.UserID = ulong.Parse(uid);
					twUser.ScreenName = firstName;

					resultUser = new User()
					{
						FirstName = firstName,
						Uid = uid,
						SerializeInfo = JsonConvert.SerializeObject(twUser),
						SocialNetwork = enSocialNetwork.Twitter				
					};

					ts.SetResult(0);

				};

				var intent = auth.GetUI(Forms.Context);
				Forms.Context.StartActivity(intent);
				await ts.Task;
			}
			catch (Exception)
			{
			}
			return resultUser;
		}
Пример #40
0
        private void TwitterLoginPost(string clientID, string secrete, string message, string link)
        {
            var auth = new OAuth1Authenticator(
                 consumerKey: clientID,
                 consumerSecret: secrete,
                 requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                 authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                 accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                 callbackUrl: new Uri("http://www.facebook.com/connect/login_success.html")
             );

            auth.Completed += (sender, eventArgs) =>
            {
                if (eventArgs.IsAuthenticated)
                {
                    //save the account
                    AccountStore.Create(Forms.Context).Save(eventArgs.Account, "Twitter");
                    //post the message
                    TwitterPost(eventArgs.Account, message, clientID, secrete, link);
                }
                else
                {
                    // The user cancelled during authentication.  do nothing

                }
            };
            Forms.Context.StartActivity(auth.GetUI(Forms.Context));
        }