internal static bool Callback(Uri uri) { // Only handle the url with our callback uri scheme if (!uri.Scheme.Equals(RedirectUri.Scheme)) { return(false); } // Ensure we have a task waiting if (tcsAccount != null && !tcsAccount.Task.IsCompleted) { try { // Parse the account from the url the app opened with var r = AuthResult.FromUri(uri); // Set our account result tcsAccount.TrySetResult(r); } catch (Exception ex) { tcsAccount.TrySetException(ex); } } tcsAccount.TrySetResult(null); return(false); }
public static bool Callback(Intent intent) { if (!isWaiting) { return(false); } isWaiting = false; try { var intentUri = new Uri(intent.Data.ToString()); // Only handle schemes we expect if (!WebUtils.CanHandleCallback(RedirectUri, intentUri)) { Failed(new NullReferenceException("Invalid Redirect URI")); return(false); } Succeeded(AuthResult.FromUri(intentUri)); return(true); } catch (Exception ex) { Failed(ex); return(false); } }
internal static bool UrlOpened(Uri uri) { // If we aren't waiting on a task, don't handle the url if (tcsAuth?.Task?.IsCompleted ?? true) { return(false); } try { // If we can't handle the url, don't if (!WebUtils.CanHandleCallback(redirectUri, uri)) { return(false); } currentViewController?.DismissViewControllerAsync(true); currentViewController = null; tcsAuth.TrySetResult(AuthResult.FromUri(uri)); return(true); } catch (Exception ex) { Console.WriteLine(ex); } return(false); }