Exemplo n.º 1
0
        public bool OpenUrlCallback(Uri uri)
        {
            // If we aren't waiting on a task, don't handle the url
            if (tcsResponse?.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;

                tcsResponse.TrySetResult(new WebAuthenticatorResult(uri));
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            return(false);
        }
Exemplo n.º 2
0
        public bool OnResumeCallback(Intent intent)
        {
            // If we aren't waiting on a task, don't handle the url
            if (tcsResponse?.Task?.IsCompleted ?? true)
            {
                return(false);
            }

            if (intent?.Data == null)
            {
                tcsResponse.TrySetCanceled();
                return(false);
            }

            try
            {
                var intentUri = new Uri(intent.Data.ToString());

                // Only handle schemes we expect
                if (!WebUtils.CanHandleCallback(currentRedirectUri, intentUri))
                {
                    tcsResponse.TrySetException(new InvalidOperationException($"Invalid Redirect URI, detected `{intentUri}` but expected a URI in the format of `{currentRedirectUri}`"));
                    return(false);
                }

                tcsResponse?.TrySetResult(new WebAuthenticatorResult(intentUri));
                return(true);
            }
            catch (Exception ex)
            {
                tcsResponse.TrySetException(ex);
                return(false);
            }
        }