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);
            }
        }
예제 #2
0
        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);
        }