public override void Login(Action <string, string> success, Action <Exception> error) { _successCallback = success; _errorCallback = error; _authenticator = null; _authenticator = new OAuth2Authenticator( ClientId, Scope, new Uri("https://www.facebook.com/dialog/oauth"), new Uri("https://www.facebook.com/connect/login_success.html"), null, false); _authenticator.Completed += (sender, e) => { string token = null; if (e.Account != null && e.Account.Properties.ContainsKey("access_token")) { token = e.Account.Properties["access_token"]; } _successCallback?.Invoke(token, null); }; _authenticator.Error += (sender, e) => { _errorCallback?.Invoke(e.Exception); }; Xamarin.Auth.Presenters.OAuthLoginPresenter presenter = null; presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(_authenticator); }
private void AuthentiacteUser() { authenticator = new OAuth2Authenticator( Constants.AndroidClientId, null, Constants.Scope, new Uri(Constants.AuthorizeUrl), new Uri(Constants.AndroidRedirectUrl), new Uri(Constants.AccessTokenUrl), null, true); authenticator.Completed += OnAuthCompletedAsync; authenticator.Error += Auth_Error; authenticator.BrowsingCompleted += Auth_BrowsingCompleted; // after initialization (creation and event subscribing) exposing local object AuthenticationState.Authenticator = authenticator; // Presenters Implementation Xamarin.Auth.Presenters.OAuthLoginPresenter presenter = null; presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); //////below is another implementation //Xamarin.Auth.XamarinForms.AuthenticatorPage ap; //ap = new Xamarin.Auth.XamarinForms.AuthenticatorPage() //{ // Authenticator = authenticator, //}; //NavigationPage np = new NavigationPage(ap); //await Navigation.PushAsync(np); }
private void Button_Clicked_1(object sender, EventArgs e) { string clientId = null; string redirectUri = null; switch (Device.RuntimePlatform) { case Device.iOS: clientId = Constants.iOSClientId; redirectUri = Constants.iOSRedirectUrl; break; case Device.Android: clientId = Constants.AndroidClientId; redirectUri = Constants.AndroidRedirectUrl; break; } var authenticator = new OAuth2Authenticator( clientId, null, Constants.Scope, new Uri(Constants.AuthorizeUrl), new Uri(redirectUri), new Uri(Constants.AccessTokenUrl), null, true); authenticator.Completed += OnAuthCompleted; authenticator.Error += OnAuthError; AuthenticationState.Authenticator = authenticator; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); }
/// <summary> /// Login /// </summary> private void Login() { string clientId = null; string redirectUri = null; switch (Device.RuntimePlatform) { case Device.iOS: clientId = Constants.iOSClientId; redirectUri = Constants.iOSRedirectUrl; break; case Device.Android: clientId = Constants.AndroidClientId; redirectUri = Constants.AndroidRedirectUrl; break; } var auth = new OAuth2Authenticator(clientId, null, Constants.Scope, new Uri(Constants.AuthorizeUrl), new Uri(redirectUri), new Uri(Constants.AccessTokenUrl), null, true); auth.Completed += Auth_Completed; auth.Error += Auth_Error;; Settings._authenticator = auth; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(auth); }
private void loginWithTwitter() { // start login with twitter string clientId = null; string redirectUri = null; switch (Device.RuntimePlatform) { case Device.iOS: clientId = Constants.iOSClientId; redirectUri = Constants.iOSRedirectUrl; break; case Device.Android: clientId = Constants.AndroidClientId; redirectUri = Constants.AndroidRedirectUrl; break; } var TwitterAuthenticator = new OAuth1Authenticator(consumerKey: "Ou4uAUPALb1YEyA06OThikxRU", consumerSecret: "cou4ELdCtRxaKwDf1t5e5CIbePzO4Xj2pLcTIK3Zi481YzvhXK", requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"), authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"), accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"), callbackUrl: new Uri("https://mobile.twitter.com/o1auth/")); TwitterAuthenticator.Completed += OnTwitterAuthenticationCompletedAsync; TwitterAuthenticator.Error += OnTwitterAuthenticationFailed; AuthenticationState.TwitterAuthenticatorState = TwitterAuthenticator; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(TwitterAuthenticator); }
void AuthorizationCodeButtonClicked(object sender, EventArgs e) { OAuth2Authenticator authenticator = new OAuth2Authenticator ( ServerInfo.ClientId, ServerInfo.ClientSecret, Scope, ServerInfo.AuthorizationEndpoint, ServerInfo.RedirectionEndpoint, ServerInfo.TokenEndpoint, null, isUsingNativeUI: true ); authenticator.Completed += OnAuthCompleted; authenticator.Error += OnAuthError; AuthenticationState.Authenticator = authenticator; if (forms_implementation_renderers) { // Renderers Implementaion //Navigation.PushModalAsync(new Xamarin.Auth.XamarinForms.AuthenticatorPage()); } else { // Presenters Implementation Xamarin.Auth.Presenters.OAuthLoginPresenter presenter = null; presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); } return; }
private void LogMeInUsingGoogle(object sender, EventArgs e) { string clientId = "77566157603-5llv064c5ukhvh0m4fs011fde4chi4h4.apps.googleusercontent.com"; string Scope = "https://www.googleapis.com/auth/userinfo.email"; string AuthorizeUrl = "https://accounts.google.com/o/oauth2/auth"; string AccessTokenUrl = "https://www.googleapis.com/oauth2/v4/token"; string RedirectUrl = "com.googleusercontent.apps.77566157603-5llv064c5ukhvh0m4fs011fde4chi4h4:/oauth2redirect";//:/oauth2redirect"; var authenticator = new OAuth2Authenticator( clientId, null, Scope, new Uri(AuthorizeUrl), new Uri(RedirectUrl), new Uri(AccessTokenUrl), null, true); authenticator.Completed += OnAuthCompletedAsync; authenticator.Error += OnAuthErrorAsync; AuthenticationState.Authenticator = authenticator; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); }
private async void LoginFb_Clicked(object sender, EventArgs e) { string clientId = String.Empty; string redirectUri = String.Empty; switch (Device.RuntimePlatform) { case Device.iOS: clientId = Constants.FacebookiOSClientId; redirectUri = Constants.FacebookiOSClientId; break; case Device.Android: clientId = Constants.FacebookAndroidClientId; redirectUri = Constants.FacebookAndroidRedirectUrl; break; } var Authenticator = new OAuth2Authenticator( clientId, Constants.FacebookScope, new Uri(Constants.FacebookAuthorizeUrl), new Uri(Constants.FacebookAndroidRedirectUrl), null, false); var Presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); Presenter.Login(Authenticator); Authenticator.Completed += Authenticator_Completed; }
private void Button_Clicked(object sender, EventArgs e) { //string client_id = "5994190"; //string redirect_uri = "https://oauth.vk.com/blank.html"; //Uri authorization_url = new Uri($"https://oauth.vk.com/authorize?client_id={client_id}&redirect_uri={redirect_uri}"); //Device.OpenUri(authorization_url); var auth = new OAuth2Authenticator ( clientId: "5994190", scope: "", authorizeUrl: new Uri("https://oauth.vk.com/authorize"), redirectUrl: new Uri("https://oauth.vk.com/blank.html"), clientSecret: null, accessTokenUrl: new Uri("https://oauth.vk.com/blank.html") ) { Title = "Авторизация", }; auth.Completed += Auth_Completed; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(auth); }
public void GoogleAuthentication() { IsLoading = true; authenticator = new Xamarin.Auth.OAuth2Authenticator ( clientId: ClientId, clientSecret: null, authorizeUrl: new Uri("https://accounts.google.com/o/oauth2/v2/auth"), redirectUrl: new Uri("com.googleusercontent.apps.604822021872-052g10g9q6qpkkr1nlk2p6r5kqk6f0ke:/oauth2redirect"), scope: "email", accessTokenUrl: new Uri("https://www.googleapis.com/oauth2/v4/token"), getUsernameAsync: null, isUsingNativeUI: true ) { AllowCancel = true, }; authenticator.Completed += OnAuthCompletedAsync; authenticator.Error += OnAuthError; AuthenticationState.Authenticator = authenticator; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); return; }
private void loginFacebook(View arg1, object arg2) { OAuth2Authenticator auth = new OAuth2Authenticator( clientId: "504256876713065", scope: "", authorizeUrl: new Uri("https://m.facebook.com/dialog/oauth/"), redirectUrl: new Uri("fb504256876713065://localhost/path"), // switch for new Native UI API // true = Android Custom Tabs and/or iOS Safari View Controller // false = Embedded Browsers used (Android WebView, iOS UIWebView) // default = false (not using NEW native UI) isUsingNativeUI: true ); accountLoggedIn = "Facebook"; auth.Completed += OnAuthCompleted; auth.Error += OnAuthError; AuthenticationState.Authenticator = auth; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(auth); }
protected override void OnAppearing() { base.OnAppearing(); try { auth = new OAuth2Authenticator ( clientId: "", clientSecret: "", scope: "r_liteprofile", authorizeUrl: new Uri("https://www.linkedin.com/oauth/v2/authorization"), redirectUrl: new Uri(""), accessTokenUrl: new Uri("https://www.linkedin.com/oauth/v2/accessToken"), getUsernameAsync: null, isUsingNativeUI: false ) { ShowErrors = true, DoNotEscapeScope = false, AccessTokenName = "oauth2_access_token" }; auth.Completed += OnAuthenticationCompleted; auth.Error += OnAuthenticationFailed; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(auth); } catch (Exception ex) { Debug.WriteLine(ex); } }
private async void LoginGoogle_ClickedAsync(object sender, EventArgs e) { string clientId = String.Empty; string redirectUri = String.Empty; switch (Device.RuntimePlatform) { case Device.iOS: redirectUri = Constants.FacebookiOSClientId; break; case Device.Android: clientId = Constants.GoogleAndroidClientId; redirectUri = Constants.GoogleAndroidRedirectUrl; break; } var authenticator = new OAuth2Authenticator( clientId, null, Constants.GoogleScope, new Uri(Constants.GoogleAuthorizeUrl), new Uri(redirectUri), new Uri(Constants.GoogleAccessTokenUrl), null, false); authenticator.Completed += OnAuthCompleted; authenticator.Error += OnAuthError; AuthenticationState.Authenticator = authenticator; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); }
public void AuthenticateAccount() { CreateAuthenticator(); var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(AuthenticationState.Authenticator); }
private void query() { AuthService.getInstance().queryUserInfo(async(result) => { if (result) { await Navigation.PushAsync(new ItemsPage()); Navigation.RemovePage(this); } else { //todo multiple times AuthService.getInstance().OnCompletedListener = async(result2) => { if (result2) { await Navigation.PushAsync(new ItemsPage()); Navigation.RemovePage(this); } else { await Navigation.PopToRootAsync(); } }; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(AuthService.getInstance().authenticator); } }); }
public static void authenticateFacebook(INavigation navigation) { var auth = new OAuth2Authenticator( clientId: "1104105879722551", scope: "email,publish_actions", authorizeUrl: new Uri("https://m.facebook.com/dialog/oauth/"), redirectUrl: new Uri("http://www.facebook.com/connect/login_success.html")); var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Completed += (sending, eventArgs) => { if (eventArgs.IsAuthenticated) { Application.Current.Properties["Account"] = eventArgs.Account; Application.Current.SavePropertiesAsync(); } else { // Login canceled Debug.WriteLine("Authentication failed."); } }; presenter.Login(auth); }
public void TriggerOAuth1Flow( string consumerKey, string consumerSecret, string requestTokenUrl, string authorizeUrl, string accessTokenUrl, string callbackUrl, GetUsernameAsyncFunc getUsernameAsync = null, bool isUsingNativeUI = false) { AuthenticationState.Authenticator = new OAuth1Authenticator( consumerKey, consumerSecret, new Uri(requestTokenUrl), new Uri(authorizeUrl), new Uri(accessTokenUrl), new Uri(callbackUrl), getUsernameAsync: getUsernameAsync, isUsingNativeUI: isUsingNativeUI); _authFlowTriggered.OnNext(Unit.Default); var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(AuthenticationState.Authenticator); }
/// <summary> To use this method you need to register the login presenter. Look in the documentation of this method (Right mouse click -> Go to definition) /// or visit: https://developer.xamarin.com/guides/xamarin-forms/cloud-services/authentication/oauth/ </summary> /// You need to create a OAuthLoginPresenter class in the iOS and Android App and register the presenter after the "global::Xamarin.Forms.Forms.Init();" line /// in the AppDelegate of the iOS App and in the MainActivity of the Android App. /// -------------------------------------------------------------------------------------------------- /// iOS OAuthLoginPresenter Class: /// namespace InstagramApp.iOS /// { /// public class OAuthLoginPresenter /// { /// UIViewController rootViewController; /// /// public void Login(Authenticator authenticator) /// { /// authenticator.Completed += AuthenticatorCompleted; /// /// /// rootViewController = UIApplication.SharedApplication.KeyWindow.RootViewController; /// rootViewController.PresentViewController((UINavigationController)authenticator.GetUI(), true, null); /// } /// /// void AuthenticatorCompleted(object sender, AuthenticatorCompletedEventArgs e) /// { /// rootViewController.DismissViewController(true, null); /// ((Authenticator)sender).Completed -= AuthenticatorCompleted; /// } /// } /// } /// -------------------------------------------------------------------------------------------------- /// iOS AppDelegate: /// namespace InstagramApp.iOS /// { /// [Register("AppDelegate")] /// public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate /// { /// public override bool FinishedLaunching(UIApplication app, NSDictionary options) /// { /// global::Xamarin.Forms.Forms.Init(); /// /// Xamarin.Auth.Presenters.OAuthLoginPresenter.PlatformLogin = (authenticator) => /// { /// var oAuthLogin = new OAuthLoginPresenter(); /// oAuthLogin.Login(authenticator); /// }; /// LoadApplication(new App()); /// /// return base.FinishedLaunching(app, options); /// } /// } /// } /// -------------------------------------------------------------------------------------------------- /// Android OAuthLoginPresenter Class: /// namespace InstagramApp.Droid /// { /// public class OAuthLoginPresenter /// { /// public void Login(Authenticator authenticator) /// { /// Xamarin.Forms.Forms.Context.StartActivity(authenticator.GetUI(Xamarin.Forms.Forms.Context)); /// } /// } /// } /// -------------------------------------------------------------------------------------------------- /// Android Manifest: /// namespace InstagramApp.Droid /// { /// [Activity(Label = "InstagramApp", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] /// public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity /// { /// protected override void OnCreate(Bundle bundle) /// { /// TabLayoutResource = Resource.Layout.Tabbar; /// ToolbarResource = Resource.Layout.Toolbar; /// /// base.OnCreate(bundle); /// /// global::Xamarin.Forms.Forms.Init(this, bundle); /// /// Xamarin.Auth.Presenters.OAuthLoginPresenter.PlatformLogin = (authenticator) => /// { /// var oAuthLogin = new OAuthLoginPresenter(); /// oAuthLogin.Login(authenticator); /// }; /// /// LoadApplication(new App()); /// } /// } /// } /// -------------------------------------------------------------------------------------------------- /// <param name="navigation"> The standard navigation element of Xamarin. (INavigation VisualElement.Navigation; just type "Navigation" in a ContentPage) </param> public static void authenticateInstagram(INavigation navigation) { var auth = new OAuth2Authenticator( Constants.ClientId, Constants.Scopes, new Uri(Constants.AuthorizationUrl), new Uri(Constants.RedirectUri)); var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Completed += (sending, eventArgs) => { if (eventArgs.IsAuthenticated) { Application.Current.Properties["Account"] = eventArgs.Account; navigation.PushAsync(new LoginSuccessPage()); } else { // Login canceled } }; presenter.Login(auth); }
public void Login() { string clientId = null; string redirectUri = null; switch (Device.RuntimePlatform) { case Device.iOS: clientId = Constants.iOSClientId; redirectUri = Constants.iOSRedirectUrl; break; case Device.Android: clientId = Constants.AndroidClientId; redirectUri = Constants.AndroidRedirectUrl; break; } var authenticator = new OAuth2Authenticator(clientId, Constants.Scope, new Uri(Constants.AuthorizeUrl), new Uri(redirectUri), null, false); authenticator.Completed += OnAuthCompleted; authenticator.Error += OnAuthError; AuthenticationState.Authenticator = authenticator; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); }
// FACEBOOK LOGIN CLICK public async void facebookLoginButtonClicked(object sender, EventArgs e) { // Initialize variables string clientID = string.Empty; string redirectURL = string.Empty; switch (Device.RuntimePlatform) { // depending on the device, get constants from Login>Constants>Constants.cs file case Device.iOS: clientID = Constant.FacebookiOSClientID; redirectURL = Constant.FacebookiOSRedirectUrl; break; case Device.Android: clientID = Constant.FacebookAndroidClientID; redirectURL = Constant.FacebookAndroidRedirectUrl; break; } // Store all the information in a variable called authenticator (for client) and presenter for http client (who is going to present the credentials) var authenticator = new OAuth2Authenticator(clientID, Constant.FacebookScope, new Uri(Constant.FacebookAuthorizeUrl), new Uri(redirectURL), null, false); var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); // Creates Completed and Error Event Handler functions; "+=" means create authenticator.Completed += FacebookAuthenticatorCompleted; authenticator.Error += FacebookAutheticatorError; // This is the actual call to Facebook presenter.Login(authenticator); // Facebooks sends back an authenticator that goes directly into the Event Handlers created above as "sender". Data is stored in arguement "e" (account, user name, access token, etc). }
private void GoogleButton_TouchUpInside(object sender, EventArgs e) { store = AccountStore.Create(); string clientId = "702647090904-45v1qskciukrf1ojmnotljnmk9k7ph23.apps.googleusercontent.com"; string redirectUri = "com.buptis.app.ios:/oauth2redirect"; account = store.FindAccountsForService("Buptis").FirstOrDefault(); var authenticator = new OAuth2Authenticator( clientId, null, "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile", //https://www.googleapis.com/auth/userinfo.profile //SADECE EMAİL GELİYOR BAK BUNA new Uri("https://accounts.google.com/o/oauth2/auth"), new Uri(redirectUri), new Uri("https://www.googleapis.com/oauth2/v4/token"), null, true); authenticator.Completed += OnAuthCompleted; authenticator.Error += OnAuthError; //GoogleVC = authenticator.GetUI(); //this.PresentViewController(GoogleVC, true, null); AuthenticationState.Authenticator = authenticator; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); }
private void signinGoogle_Clicked(System.Object sender, System.EventArgs e) { string clientId = null; string redirectUrl = null; switch (Device.RuntimePlatform) { case Device.Android: clientId = Constants.AndroidClientId; redirectUrl = Constants.AndroidRedirectUrl; break; } account = store.FindAccountsForService(Constants.AppName).FirstOrDefault(); var authenticator = new OAuth2Authenticator( clientId, null, Constants.Scope, new Uri(Constants.AuthorizeUrl), new Uri(redirectUrl), new Uri(Constants.AccessTokenUrl), null, true); authenticator.Completed += OnAuthCompleted; authenticator.Error += OnAuthError; AuthenticationState.Authenticator = authenticator; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); }
void Login() { //store = AccountStore.Create(); string clientId = null; string redirectUri = null; switch (Device.RuntimePlatform) { case Device.iOS: clientId = Constants.iOSClientId; redirectUri = Constants.iOSRedirectUrl; break; case Device.Android: clientId = Constants.AndroidClientId; redirectUri = Constants.AndroidRedirectUrl; break; } //account = (await SecureStorageAccountStore.FindAccountsForServiceAsync(Constants.AppName)).FirstOrDefault(); var authenticator = new OAuth2Authenticator(clientId, null, Constants.Scope, new Uri(Constants.AuthorizeUrl), new Uri(redirectUri), new Uri(Constants.AccessTokenUrl), null, true); authenticator.Completed += OnAuthCompleted; authenticator.Error += OnAuthError; AuthenticationState.Authenticator = authenticator; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); }
private void LoginTwitter(object sender, EventArgs e) { ViewModel.LoginCommand.Execute(); var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(ViewModel.Authenticator); }
public async Task OAuthLoginAsync(SNSProviderType provider) { if (!await WebApiService.CheckInternetConnection()) { _isAuthenticated = false; return; } var oAuth = OAuthProviderFactory.CreateProvider(provider); Cur_Provider = oAuth.Provider; if (oAuth.Provider == SNSProviderType.Google) { var googleOAuthService = DependencyService.Resolve <IGoogleOAuth>(); googleOAuthService.Login(oAuth.ClientId); } else if (oAuth.Provider == SNSProviderType.Facebook) { Cur_Authenticator = new OAuth2Authenticator( oAuth.ClientId, oAuth.Scope, new Uri(oAuth.AuthorizationUrl), new Uri(oAuth.RedirectUrl)); Cur_Authenticator.Completed += OnOAuthComplete; Cur_Authenticator.Error += OnOAuthError; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(Cur_Authenticator); } }
public void FacebookSignInClick(System.Object sender, System.EventArgs e) { string clientID = string.Empty; string redirectURL = string.Empty; switch (Device.RuntimePlatform) { case Device.iOS: clientID = Constant.FacebookiOSClientID; redirectURL = Constant.FacebookiOSRedirectUrl; break; case Device.Android: clientID = Constant.FacebookAndroidClientID; redirectURL = Constant.FacebookAndroidRedirectUrl; break; } var authenticator = new OAuth2Authenticator(clientID, Constant.FacebookScope, new Uri(Constant.FacebookAuthorizeUrl), new Uri(redirectURL), null, false); var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); authenticator.Completed += FacebookAuthenticatorCompleted; authenticator.Error += FacebookAutheticatorError; presenter.Login(authenticator); }
public async void GoogleSignInClick(System.Object sender, System.EventArgs e) { string clientId = string.Empty; string redirectUri = string.Empty; switch (Device.RuntimePlatform) { case Device.iOS: clientId = Constant.GoogleiOSClientID; redirectUri = Constant.GoogleRedirectUrliOS; break; case Device.Android: clientId = Constant.GoogleAndroidClientID; redirectUri = Constant.GoogleRedirectUrlAndroid; break; } var authenticator = new OAuth2Authenticator(clientId, string.Empty, Constant.GoogleScope, new Uri(Constant.GoogleAuthorizeUrl), new Uri(redirectUri), new Uri(Constant.GoogleAccessTokenUrl), null, true); var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); authenticator.Completed += GoogleAuthenticatorCompleted; authenticator.Error += GoogleAuthenticatorError; AuthenticationState.Authenticator = authenticator; presenter.Login(authenticator); }
private void PresentUILoginScreen(OAuth2Authenticator authenticator) { if (forms_implementation_renderers) { // Renderers Implementaion Xamarin.Auth.XamarinForms.AuthenticatorPage ap; ap = new Xamarin.Auth.XamarinForms.AuthenticatorPage() { Authenticator = authenticator, }; NavigationPage np = new NavigationPage(ap); if (navigation_push_modal == true) { System.Diagnostics.Debug.WriteLine("Presenting"); System.Diagnostics.Debug.WriteLine(" PushModal"); System.Diagnostics.Debug.WriteLine(" Custom Renderers"); Navigation.PushModalAsync(np); } else { System.Diagnostics.Debug.WriteLine("Presenting"); System.Diagnostics.Debug.WriteLine(" Push"); System.Diagnostics.Debug.WriteLine(" Custom Renderers"); Navigation.PushAsync(np); } } else { // Presenters Implementation if (navigation_push_modal == true) { System.Diagnostics.Debug.WriteLine("Presenting"); System.Diagnostics.Debug.WriteLine(" PushModal"); System.Diagnostics.Debug.WriteLine(" Presenters"); Xamarin.Auth.Presenters.OAuthLoginPresenter presenter = null; presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); } else { System.Diagnostics.Debug.WriteLine("Presenting"); System.Diagnostics.Debug.WriteLine(" Push"); System.Diagnostics.Debug.WriteLine(" Presenters"); Xamarin.Auth.Presenters.OAuthLoginPresenter presenter = null; presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); } } return; }
public void DoAuthetication() { authenticator.Completed += OnAuthCompleted; authenticator.Error += OnAuthError; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); }
void OnButtonClicked(object sender, EventArgs e) { System.Diagnostics.Debug.WriteLine("onButtonClicked() triggered"); var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(auth); }