Exemplo n.º 1
0
        private async void OAuth2Authenticator_Completed(object sender, AuthenticatorCompletedEventArgs e)
        {
            if (e.IsAuthenticated)
            {
                try
                {
                    await SecureStorage.SetAsync(OAuth2ProviderType.ToString(), JsonConvert.SerializeObject(e.Account.Properties));
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }

                string email = string.Empty;

                switch (OAuth2ProviderType)
                {
                case OAuth2ProviderType.NONE:
                    break;

                case OAuth2ProviderType.TRADITIONAL:
                    break;

                case OAuth2ProviderType.FACEBOOK:
                    email = await ProviderService.GetFacebookEmailAsync();

                    break;

                case OAuth2ProviderType.GOOGLE:
                    email = await ProviderService.GetGoogleEmailAsync();

                    break;

                case OAuth2ProviderType.MICROSOFT:
                    email = await ProviderService.GetMicrosoftEmailAsync();

                    break;
                }

                await SecureStorage.SetAsync("Email", email);

                await SecureStorage.SetAsync("Provider", OAuth2ProviderType.ToString());

                await Application.Current.MainPage.Navigation.PushModalAsync(new MainPage());
            }
            else
            {
                oAuth2Authenticator.OnCancelled();
                oAuth2Authenticator = default(OAuth2Authenticator);
            }
        }