protected void ProviderSamplesList_Handle_ItemSelected(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
        {
            Type   selection_type = e.SelectedItem.GetType();
            string selection      = selection_type.ToString().Replace("Xamarin.Auth.ProviderSamples.", "");

            System.Diagnostics.Debug.WriteLine($"    Provider Sample");
            System.Diagnostics.Debug.WriteLine($"        Selection = {selection}");

            Xamarin.Auth.WebAuthenticator authenticator = null;

            Xamarin.Auth.ProviderSamples.Helpers.OAuth1 oauth1 = null;
            Xamarin.Auth.ProviderSamples.Helpers.OAuth2 oauth2 = null;

            oauth2 = Activator.CreateInstance(selection_type) as Xamarin.Auth.ProviderSamples.Helpers.OAuth2;

            if (null == oauth2)
            {
                oauth1 = Activator.CreateInstance(selection_type) as Xamarin.Auth.ProviderSamples.Helpers.OAuth1;

                if (null == oauth1)
                {
                    throw new ArgumentException("Not OAuth object!");
                }

                authenticator = Map(oauth1);
            }

            authenticator = Map(oauth2);

            return;
        }
        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;
        }
        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();
            Type page_type = auth.GetUI();

            //(System.Windows.Application.Current.RootVisual as PhoneApplicationFrame).Navigate(uri);
            Windows.UI.Xaml.Controls.Page this_page = this;
            this_page.Frame.Navigate(page_type, auth);

            return;
        }
        public OAuth1Authenticator Map(Xamarin.Auth.ProviderSamples.Helpers.OAuth1 oauth1)
        {
            OAuth1Authenticator o1a = null; //new OAuth1Authenticator();

            System.Diagnostics.Debug.WriteLine(o1a?.ToString());

            return(o1a);
        }
        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;
        }
Exemple #6
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
                    )
            {
                ShowErrors  = false,
                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
            UIKit.UIViewController ui_object = Auth1.GetUI();

            if (Auth1.IsUsingNativeUI == true)
            {
                // Step 2.1 Creating Login UI
                // In order to access SFSafariViewController API the cast is neccessary
                SafariServices.SFSafariViewController c = null;
                c = (SafariServices.SFSafariViewController)ui_object;
                //  add custom schema (App Linking) handling
                //    in AppDelegate.cs
                //         public override bool OpenUrl
                //                                (
                //                                    UIApplication application,
                //                                    NSUrl url,
                //                                    string sourceApplication,
                //                                    NSObject annotation
                //                                )
                //
                //  NOTE[s]
                //  *   custom scheme support only
                //      xamarinauth://localhost
                //      xamarin-auth://localhost
                //      xamarin.auth://localhost
                //  *   no http[s] scheme support

                // 2.2 Customizing the UI - Native UI [OPTIONAL]
                if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
                {
                    c.PreferredBarTintColor     = color_xamarin_blue;
                    c.PreferredControlTintColor = UIColor.White;
                }
                else
                {
                    c.View.TintColor = color_xamarin_blue;
                }

                Action view_controller_customization =
                    () =>
                {
                    c.NavigationController.NavigationBar.TintColor = color_xamarin_blue;
                };

                // Step 3 Present/Launch the Login UI
                PresentViewController(c, true, view_controller_customization);
            }
            else
            {
                // Step 3 Present/Launch the Login UI
                PresentViewController(ui_object, true, null);
            }

            return;
        }