private void Authenticate(OAuth2ProviderType providerType) { oAuth2Authenticator = OAuthAuthenticatorHelper.CreateOAuth2(providerType); oAuth2Authenticator.Completed += OAuth2Authenticator_Completed; oAuth2Authenticator.Error += OAuth2Authenticator_Error; OAuth2ProviderType = providerType; var presenter = new OAuthLoginPresenter(); // This is workaround for iOS because when open presenter on iOS, // view is not correctly shown. Then is necessary modify view on // iOS LoginPageRenderer renderer. On Android, view is correctly shown. switch (Device.RuntimePlatform) { case Device.iOS: if (providerType == OAuth2ProviderType.FACEBOOK) { OnPresenter?.Invoke(oAuth2Authenticator, EventArgs.Empty); } else { presenter.Login(oAuth2Authenticator); } break; case Device.Android: case Device.UWP: presenter.Login(oAuth2Authenticator); break; } }
public static OAuth2Authenticator CreateOAuth2(OAuth2ProviderType socialLoginProvider) { switch (socialLoginProvider) { case OAuth2ProviderType.FACEBOOK: oAuth2Authenticator = new OAuth2Authenticator( clientId: FacebookConfiguration.ClientId, scope: FacebookConfiguration.Scope, authorizeUrl: new Uri(FacebookConfiguration.AuthorizeUrl), redirectUrl: new Uri(FacebookConfiguration.RedirectUrl), getUsernameAsync: null, isUsingNativeUI: FacebookConfiguration.IsUsingNativeUI) { AllowCancel = true, ShowErrors = false, ClearCookiesBeforeLogin = true }; break; case OAuth2ProviderType.GOOGLE: oAuth2Authenticator = new OAuth2Authenticator( clientId: GoogleConfiguration.ClientId, clientSecret: GoogleConfiguration.ClientSecret, scope: GoogleConfiguration.Scope, authorizeUrl: new Uri(GoogleConfiguration.AuthorizeUrl), redirectUrl: new Uri(GoogleConfiguration.RedirectUrl), getUsernameAsync: null, isUsingNativeUI: GoogleConfiguration.IsUsingNativeUI, accessTokenUrl: new Uri(GoogleConfiguration.AcessTokenUrl)) { AllowCancel = true, ShowErrors = false, ClearCookiesBeforeLogin = true }; break; case OAuth2ProviderType.MICROSOFT: oAuth2Authenticator = new OAuth2Authenticator( clientId: MicrosoftConfiguration.ClientId, clientSecret: MicrosoftConfiguration.ClientSecret, scope: MicrosoftConfiguration.Scope, authorizeUrl: new Uri(MicrosoftConfiguration.AuthorizeUrl), redirectUrl: new Uri(MicrosoftConfiguration.RedirectUrl), getUsernameAsync: null, isUsingNativeUI: MicrosoftConfiguration.IsUsingNativeUI, accessTokenUrl: new Uri(MicrosoftConfiguration.AcessTokenUrl)) { AllowCancel = true, ShowErrors = false, ClearCookiesBeforeLogin = true }; break; } AuthenticationState = oAuth2Authenticator; return(oAuth2Authenticator); }
public async void ExecuteOnPageAppearing() { UserEmail = await SecureStorage.GetAsync("Email"); string socialProvider = await SecureStorage.GetAsync("Provider"); OAuth2ProviderType = (OAuth2ProviderType)Enum.Parse(typeof(OAuth2ProviderType), socialProvider); var token = string.Empty; switch (OAuth2ProviderType) { case OAuth2ProviderType.NONE: break; case OAuth2ProviderType.TRADITIONAL: break; case OAuth2ProviderType.FACEBOOK: token = await SecureStorage.GetAsync(OAuth2ProviderType.ToString()); FacebookCredentials = JsonConvert.DeserializeObject <FacebookToken>(token); ProviderToken = FacebookCredentials.AccessToken; ProviderName = OAuth2ProviderType.FACEBOOK.ToString(); break; case OAuth2ProviderType.GOOGLE: token = await SecureStorage.GetAsync(OAuth2ProviderType.ToString()); GoogleCredentials = JsonConvert.DeserializeObject <GoogleToken>(token); ProviderToken = GoogleCredentials.AccessToken; ProviderName = OAuth2ProviderType.GOOGLE.ToString(); break; case OAuth2ProviderType.MICROSOFT: token = await SecureStorage.GetAsync(OAuth2ProviderType.ToString()); MicrosoftCredentials = JsonConvert.DeserializeObject <MicrosoftToken>(token); ProviderToken = MicrosoftCredentials.AccessToken; ProviderName = OAuth2ProviderType.MICROSOFT.ToString(); break; } }
public static OAuth2Authenticator CreateOAuth2(OAuth2ProviderType socialLoginType) { switch (socialLoginType) { case OAuth2ProviderType.GOOGLE: oAuth2Authenticator = new OAuth2Authenticator( clientId: AppConstants.GoogleClientId, clientSecret: string.Empty, scope: AppConstants.Scope, authorizeUrl: new Uri(AppConstants.GoogleAuthorizeUrl), redirectUrl: new Uri(AppConstants.GoogleRedirectUrl), getUsernameAsync: null, isUsingNativeUI: AppConstants.GoogleIsUsingNativeUI, accessTokenUrl: new Uri(AppConstants.GoogleAccessTokenUrl)); break; } AuthenticationState = oAuth2Authenticator; return(oAuth2Authenticator); }
public static OAuth2Authenticator CreateOAuth2(OAuth2ProviderType socialLoginProvider) { switch (socialLoginProvider) { case OAuth2ProviderType.FACEBOOK: oAuth2Authenticator = new OAuth2Authenticator( clientId: FacebookConfiguration.ClientId, scope: FacebookConfiguration.Scope, authorizeUrl: new Uri(FacebookConfiguration.AuthorizeUrl), redirectUrl: new Uri(FacebookConfiguration.RedirectUrl), getUsernameAsync: null, isUsingNativeUI: FacebookConfiguration.IsUsingNativeUI) { AllowCancel = true, ShowErrors = false, ClearCookiesBeforeLogin = true }; break; } AuthenticationState = oAuth2Authenticator; return(oAuth2Authenticator); }