void BeginLoadingInitialUrl() { authenticator.GetInitialUrlAsync().ContinueWith(t => { if (t.IsFaulted) { keepTryingAfterError = false; authenticator.OnError(t.Exception); } else { // Delete cookies so we can work with multiple accounts if (this.authenticator.ClearCookiesBeforeLogin) { WebAuthenticator.ClearCookies(); } // // Begin displaying the page // Uri uri = t.Result; LoadInitialUrl(uri); } }, TaskScheduler.FromCurrentSynchronizationContext()); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { if (null == authenticator) { Type type_authenticator = e.Parameter.GetType(); if (type_authenticator == typeof(OAuth1Authenticator)) { authenticator = e.Parameter as OAuth1Authenticator; } else if (type_authenticator == typeof(OAuth2Authenticator)) { authenticator = e.Parameter as OAuth2Authenticator; } else { System.Diagnostics.Debug.WriteLine($"Invalid Authenticator {type_authenticator}"); throw new Xamarin.Auth.AuthException($"Invalid Authenticator {type_authenticator}"); } } url_initial = this.authenticator.GetInitialUrlAsync().Result; this.browser.Navigate(url_initial); System.Diagnostics.Debug.WriteLine("OnNavigatedTo authenticator = " + authenticator.Title); authenticator.Completed += auth_Completed; authenticator.Error += auth_Error; url_initial = await authenticator.GetInitialUrlAsync(); base.OnNavigatedTo(e); return; }
protected override async void OnNavigatedTo(NavigationEventArgs e) { authenticator = e.Parameter as OAuth2Authenticator; if (null == authenticator) { authenticator = e.Parameter as OAuth1Authenticator; } if (null == authenticator) { // Not OAuth1 and OAuth2 throw new InvalidOperationException("Unknown OAuth type"); } url_initial = this.authenticator.GetInitialUrlAsync().Result; this.browser.Navigate(url_initial); System.Diagnostics.Debug.WriteLine("OnNavigatedTo authenticator = " + authenticator.Title); authenticator.Completed += auth_Completed; authenticator.Error += auth_Error; url_initial = await authenticator.GetInitialUrlAsync(); base.OnNavigatedTo(e); return; }
protected override async void OnNavigatedTo(NavigationEventArgs e) { if (null == authenticator) { authenticator = e.Parameter as WebRedirectAuthenticator; if (authenticator == null) { System.Diagnostics.Debug.WriteLine($"Invalid Authenticator {e.Parameter?.GetType().ToString() ?? "null"}"); throw new Xamarin.Auth.Compat.AuthException($"Invalid Authenticator {e.Parameter?.GetType().ToString() ?? "null"}"); } } url_initial = this.authenticator.GetInitialUrlAsync().Result; this.browser.Navigate(url_initial); System.Diagnostics.Debug.WriteLine("OnNavigatedTo authenticator = " + authenticator.Title); authenticator.Completed += auth_Completed; authenticator.Error += auth_Error; url_initial = await authenticator.GetInitialUrlAsync(); base.OnNavigatedTo(e); return; }
protected override async void OnNavigatedTo(NavigationEventArgs e) { authenticator = (OAuth2Authenticator)e.Parameter; url_initial = this.authenticator.GetInitialUrlAsync().Result; this.browser.Navigate(url_initial); System.Diagnostics.Debug.WriteLine("OnNavigatedTo authenticator = " + authenticator.Title); authenticator.Completed += auth_Completed; authenticator.Error += auth_Error; url_initial = await authenticator.GetInitialUrlAsync(); base.OnNavigatedTo(e); return; }