Exemplo n.º 1
0
        protected override void OnElementChanged(ElementChangedEventArgs <Page> e)
        {
            base.OnElementChanged(e);

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

                var auth = new global::Xamarin.Auth.OAuth2Authenticator
                           (
                    clientId: App.Current.Properties ["clientId"].ToString(),
                    scope: App.Current.Properties ["scope"].ToString(),
                    authorizeUrl: new Uri(App.Current.Properties ["authorizeUrl"].ToString()),
                    redirectUrl: new Uri(App.Current.Properties ["redirectUrl"].ToString())
                           );

                auth.Completed += auth_Completed;


                //auth.AllowCancel = false;
                activity.StartActivity(auth.GetUI(activity));
                done = true;
            }
        }
Exemplo n.º 2
0
        private void Login(HolisticWare.Auth.OAuth2 oauth2)
        {
            global::Xamarin.Auth.OAuth2Authenticator auth = null;

            if (
                null == oauth2.OAuth1_UriAccessToken)
            {
                try
                {
                    auth =
                        new global::Xamarin.Auth.OAuth2Authenticator(
                            clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                            scope: oauth2.OAuth2_Scope,
                            authorizeUrl: oauth2.OAuth_UriAuthorization,
                            redirectUrl: oauth2.OAuth_UriCallbackAKARedirect,
                            getUsernameAsync: null
                            );
                }
                catch (System.Exception exc)
                {
                    throw exc;
                }
            }
            else
            {
                try
                {
                    auth =
                        new global::Xamarin.Auth.OAuth2Authenticator
                        (
                            clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                            clientSecret: oauth2.OAuth1_SecretKey_ConsumerSecret_APISecret,
                            scope: oauth2.OAuth2_Scope,
                            authorizeUrl: oauth2.OAuth_UriAuthorization,
                            redirectUrl: oauth2.OAuth_UriCallbackAKARedirect,
                            accessTokenUrl: oauth2.OAuth1_UriAccessToken,
                            getUsernameAsync: null
                        );
                }
                catch (System.Exception exc)
                {
                    throw exc;
                }
            }
            auth.Completed += auth_Completed;


            Uri uri = auth.GetUI();
            var rv  = System.Windows.Application.Current.RootVisual;

            Microsoft.Phone.Controls.PhoneApplicationFrame paf = null;

            paf = rv as Microsoft.Phone.Controls.PhoneApplicationFrame;
            paf.Navigate(uri);

            return;
        }
Exemplo n.º 3
0
        private void Login(HolisticWare.Auth.OAuth2 oauth2)
        {
            global::Xamarin.Auth.OAuth2Authenticator auth = null;

            if (
                null == oauth2.OAuth1_UriAccessToken)
            {
                try
                {
                    auth =
                        new global::Xamarin.Auth.OAuth2Authenticator
                        (
                            clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                            scope: oauth2.OAuth2_Scope,
                            authorizeUrl: oauth2.OAuth_UriAuthorization,
                            redirectUrl: oauth2.OAuth_UriCallbackAKARedirect,
                            getUsernameAsync: null
                        );
                    auth.Error += Auth_Error;
                }
                catch (System.Exception exc)
                {
                    throw exc;
                }
            }
            else
            {
                try
                {
                    auth =
                        new global::Xamarin.Auth.OAuth2Authenticator
                        (
                            clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                            clientSecret: oauth2.OAuth1_SecretKey_ConsumerSecret_APISecret,
                            scope: oauth2.OAuth2_Scope,
                            authorizeUrl: oauth2.OAuth_UriAuthorization,
                            redirectUrl: oauth2.OAuth_UriCallbackAKARedirect,
                            accessTokenUrl: oauth2.OAuth1_UriAccessToken,
                            getUsernameAsync: null
                        );
                }
                catch (System.Exception exc)
                {
                    throw exc;
                }
            }
            auth.Completed += auth_Completed;

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

            return;
        }
Exemplo n.º 4
0
		private void Login(Xamarin.Auth.Helpers.OAuth2 oauth2)
		{
			global::Xamarin.Auth.OAuth2Authenticator auth = null;

			if (
				null == oauth2.OAuth1_UriAccessToken)
			{
				try
				{
					auth = 
						new global::Xamarin.Auth.OAuth2Authenticator 
						(
						clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
						scope: oauth2.OAuth2_Scope,
						authorizeUrl: oauth2.OAuth_UriAuthorization,
						redirectUrl: oauth2.OAuth_UriCallbackAKARedirect,
						getUsernameAsync: null
					);
				}
				catch (System.Exception exc)
				{
					throw exc;
				}
			}
			else
			{
				auth = 
					new global::Xamarin.Auth.OAuth2Authenticator 
						(
						clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer, 
						clientSecret: oauth2.OAuth1_SecretKey_ConsumerSecret_APISecret,
						scope: oauth2.OAuth2_Scope,
						authorizeUrl: oauth2.OAuth_UriAuthorization,
						redirectUrl: oauth2.OAuth_UriCallbackAKARedirect,
						accessTokenUrl: oauth2.OAuth1_UriAccessToken,
						getUsernameAsync: null
						);

			}
			auth.Completed += Auth_Completed;

			//PresentViewController (auth.GetUI (), true, null);

			return;
		}