예제 #1
0
        protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
        {
            base.OnElementChanged(e);
            var activity = this.Context as Activity;
            var loginPage = e.NewElement as LoginPage;            
            
            var authUrl = new Uri(WebAPI.BaseURI, loginPage.AuthProvider.Url);
            var auth = new SocialLoginAuthenticator(authUrl, WebAPI.BaseURI);

            auth.Completed += async (sender, eventArgs) =>
            {
                if (eventArgs.IsAuthenticated)
                {                                        
                    await loginPage.CompleteLoginAsync(eventArgs.Account.Properties["access_token"]);
                }
                else
                {                    
                    System.Diagnostics.Debug.WriteLine("LoginPage failed to authenticate or was canceled.");                   
                    await loginPage.CancelLoginAsync();
                }

            };

            activity.StartActivity(auth.GetUI(activity));
        }
예제 #2
0
        protected override void OnElementChanged(ElementChangedEventArgs <Page> e)
        {
            base.OnElementChanged(e);
            var activity  = this.Context as Activity;
            var loginPage = e.NewElement as LoginPage;

            var authUrl = new Uri(WebAPI.BaseURI, loginPage.AuthProvider.Url);
            var auth    = new SocialLoginAuthenticator(authUrl, WebAPI.BaseURI);

            auth.Completed += async(sender, eventArgs) =>
            {
                if (eventArgs.IsAuthenticated)
                {
                    await loginPage.CompleteLoginAsync(eventArgs.Account.Properties["access_token"]);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("LoginPage failed to authenticate or was canceled.");
                    await loginPage.CancelLoginAsync();
                }
            };

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