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;
        }
        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;
        }
        static partial void SetPublicDemoDataLinkedInOAuth1()
        {
            oauth1 = new Xamarin.Auth._MobileServices.Helpers.OAuth1()
            {
                Description = "LinkedIn OAuth1",
                OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer = "",
                OAuth1_SecretKey_ConsumerSecret_APISecret            = "",
                OAuth1_UriRequestToken       = new Uri("https://api.linkedin.com/uas/oauth/requestToken"),
                OAuth_UriAuthorization       = new Uri("https://api.linkedin.com/uas/oauth/authorize"),
                OAuth_UriCallbackAKARedirect = new Uri("http://xamarin.com"),
                OAuth1_UriAccessToken        = new Uri("https://api.linkedin.com/uas/oauth/accessToken"),
                AllowCancel = true,
            };

            if (TestCases.ContainsKey(oauth1.Description))
            {
                TestCases[oauth1.Description] = oauth1;
            }
            else
            {
                TestCases.Add(oauth1.Description, oauth1);
            }

            return;
        }
コード例 #4
0
        public void AuthenticateOAuth1(Xamarin.Auth._MobileServices.Helpers.OAuth1 oauth1)
        {
            page = new PageOAuth
                   (
                oauth1.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                oauth1.OAuth1_SecretKey_ConsumerSecret_APISecret,
                oauth1.OAuth1_UriRequestToken,
                oauth1.OAuth_UriAuthorization,
                oauth1.OAuth_UriAccessToken,
                oauth1.OAuth_UriCallbackAKARedirect,
                null,
                true
                   );

            Navigation.PushAsync(page);

            return;
        }
コード例 #5
0
        private void Authenticate(Xamarin.Auth._MobileServices.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
            }

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

            return;
        }
コード例 #6
0
        private void Authenticate(Xamarin.Auth._MobileServices.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;
        }
        private void Authenticate(Xamarin.Auth._MobileServices.Helpers.OAuth1 oauth1)
        {
            //-------------------------------------------------------------
            // WalkThrough Step 1
            //      setting up Authenticator object
            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,
                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,
            };
            //-------------------------------------------------------------


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



            //#####################################################################
            // WalkThrough Step 2
            //      creating Presenter (UI) for specific platform
            // Xamarin.Auth API - Breaking Change
            //      old API returned UIKit.UIViewController
            //UIViewController ui_controller = auth.GetUI ();
            //      new API returns System.Object
            UIViewController ui_object = Auth1.GetUI();

            if (Auth1.IsUsingNativeUI == true)
            {
                //=================================================================
                // WalkThrough Step 2.1
                //      casting UI object to proper type to work with
                //
                // Xamarin.Auth API - Native UI support
                //      *   Android - [Chrome] Custom Tabs on Android
                //          Android.Support.CustomTabs
                //          and
                //      *   iOS -  SFSafariViewController
                //          SafariServices.SFSafariViewController
                // on 2014-04-20 google (and some other providers) will work only with this API
                //
                //
                //  2017-03-25
                //      NEW UPCOMMING API undocumented work in progress
                //      soon to be default
                //      optional API in the future (for backward compatibility)
                //
                //  required part
                //  add
                //     following code:
                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
                //------------------------------------------------------------

                //------------------------------------------------------------
                // WalkThrough Step 2.2
                //      UI Customisation
                //      [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;
                };
                //------------------------------------------------------------

                //------------------------------------------------------------
                // WalkThrough Step 3
                //      Launching UI
                //      [REQUIRED]
                PresentViewController(c, true, view_controller_customization);
                //------------------------------------------------------------
                //=================================================================
            }
            else
            {
                //=================================================================
                // WalkThrough Step 2.1
                //      casting UI object to proper type to work with
                //
                // Xamarin.Auth API - Embedded Browsers support
                //     - Android - Intent to start Activity with WebView
                //     - iOS - UIViewController with UIWebView or WKWebView
                //
                // on 2014-04-20 google (and some other providers) will work only with this API
                //
                //  2017-03-25
                //      soon to be non-default
                //      optional API in the future (for backward compatibility)
                //
                //------------------------------------------------------------

                //------------------------------------------------------------
                // WalkThrough Step 3
                //      Launching UI
                //      [REQUIRED]
                PresentViewController(ui_object, true, null);
                //=================================================================
            }
            //#####################################################################

            return;
        }
コード例 #8
0
        public void OnItemSelected(object sender, ItemTappedEventArgs args_tapped)
        {
            object item = args_tapped.Item;

            KeyValuePair <string, string> kvp = (KeyValuePair <string, string>)item;

            string provider = kvp.Value;

            switch (provider)
            {
            case "Facebook OAuth2":
                Xamarin.Auth._MobileServices.Helpers.OAuth2 oauth_facebook = null;
                oauth_facebook = Data.TestCases [provider] as Xamarin.Auth._MobileServices.Helpers.OAuth2;
                AuthenticateOAuth2(oauth_facebook);
                break;

            case "Twitter OAuth1":
                Xamarin.Auth._MobileServices.Helpers.OAuth1 oauth_twitter = null;
                oauth_twitter = Data.TestCases[provider] as Xamarin.Auth._MobileServices.Helpers.OAuth1;
                AuthenticateOAuth1(oauth_twitter);
                break;

            case "Google OAuth2":
                Xamarin.Auth._MobileServices.Helpers.OAuth2 oauth_google = null;
                oauth_google = Data.TestCases[provider] as Xamarin.Auth._MobileServices.Helpers.OAuth2;
                AuthenticateOAuth2(oauth_google);
                break;

            case "Microsoft Live OAuth2":
                Xamarin.Auth._MobileServices.Helpers.OAuth2 oauth_mslive = null;
                oauth_mslive = Data.TestCases[provider] as Xamarin.Auth._MobileServices.Helpers.OAuth2;
                AuthenticateOAuth2(oauth_mslive);
                break;

            case "LinkedIn OAuth1":
                Xamarin.Auth._MobileServices.Helpers.OAuth1 oauth_linkedin1 = null;
                oauth_linkedin1 = Data.TestCases[provider] as Xamarin.Auth._MobileServices.Helpers.OAuth1;
                AuthenticateOAuth1(oauth_linkedin1);
                break;

            case "LinkedIn OAuth2":
                Xamarin.Auth._MobileServices.Helpers.OAuth2 oauth_linkedin2 = null;
                oauth_linkedin2 = Data.TestCases[provider] as Xamarin.Auth._MobileServices.Helpers.OAuth2;
                AuthenticateOAuth2(oauth_linkedin2);
                break;

            case "Github OAuth2":
                Xamarin.Auth._MobileServices.Helpers.OAuth2 oauth_github = null;
                oauth_github = Data.TestCases[provider] as Xamarin.Auth._MobileServices.Helpers.OAuth2;
                AuthenticateOAuth2(oauth_github);
                break;

            case "Instagram OAuth2":
                Xamarin.Auth._MobileServices.Helpers.OAuth2 oauth_instagram = null;
                oauth_instagram = Data.TestCases[provider] as Xamarin.Auth._MobileServices.Helpers.OAuth2;
                AuthenticateOAuth2(oauth_instagram);
                break;

            default:
                DisplayAlert("Error", "Unknown OAuth Provider!", "OK");
                break;
            }
            ;

            this.Navigation.PushAsync(page);

            return;
        }
コード例 #9
0
        private void Authenticate(Xamarin.Auth._MobileServices.Helpers.OAuth1 oauth1)
        {
            //-------------------------------------------------------------
            // WalkThrough Step 1
            //      setting up Authenticator object
            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,
                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;

            //#####################################################################
            // WalkThrough Step 2
            //      creating Presenter (UI) for specific platform
            // Xamarin.Auth API - Breaking Change
            //      old API returned global::Android.Content.Intent
            //Intent ui_intent_as_object = auth.GetUI ();
            //      new API returns System.Object
            global::Android.Content.Intent ui_object = Auth1.GetUI(this);

            if (Auth1.IsUsingNativeUI == true)
            {
                //=================================================================
                // WalkThrough Step 2.1
                //      casting UI object to proper type to work with
                //
                // Xamarin.Auth API - Native UI support
                //      *   Android - [Chrome] Custom Tabs on Android
                //          Android.Support.CustomTabs
                //          and
                //      *   iOS -  SFSafariViewController
                //          SafariServices.SFSafariViewController
                // on 2014-04-20 google (and some other providers) will work only with this API
                //
                //
                //  2017-03-25
                //      NEW UPCOMMING API undocumented work in progress
                //      soon to be default
                //      optional API in the future (for backward compatibility)
                //
                //  required part
                //  add
                //     following code:

                //  add custom schema (App Linking) handling
                //      1.  add Activity with IntentFilter to the app
                //          1.1. Define sheme[s] and host[s] in the IntentFilter
                //          1.2. in Activity's OnCreate extract URL with custom schema from Intent
                //          1.3. parse OAuth data from URL obtained in 1.2.
                //  NOTE[s]
                //  *   custom scheme support only
                //      xamarinauth://localhost
                //      xamarin-auth://localhost
                //      xamarin.auth://localhost
                //  *   no http[s] scheme support
                //------------------------------------------------------------
            }

            //------------------------------------------------------------
            // WalkThrough Step 3
            //      Launching UI
            //      [REQUIRED]
            StartActivity(ui_object);
            //------------------------------------------------------------

            return;
        }