Ejemplo n.º 1
0
        internal static Task <BrowserResult> Start(BrowserOptions options, ASWebAuthenticationSessionOptions sessionOptions = null)
        {
            var tcs = new TaskCompletionSource <BrowserResult>();

            ASWebAuthenticationSession asWebAuthenticationSession = null;

            asWebAuthenticationSession = new ASWebAuthenticationSession(
                new NSUrl(options.StartUrl),
                options.EndUrl,
                (callbackUrl, error) =>
            {
                tcs.SetResult(CreateBrowserResult(callbackUrl, error));
                asWebAuthenticationSession.Dispose();
            });

            if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
            {
                // iOS 13 requires the PresentationContextProvider set
                asWebAuthenticationSession.PresentationContextProvider = new PresentationContextProviderToSharedKeyWindow();
                // PrefersEphemeralWebBrowserSession is only available on iOS 13 and up.
                asWebAuthenticationSession.PrefersEphemeralWebBrowserSession = sessionOptions != null ? sessionOptions.PrefersEphemeralWebBrowserSession : false;
            }

            asWebAuthenticationSession.Start();

            return(tcs.Task);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of the ASWebAuthenticationSession Browser.
 /// </summary>
 /// <param name="sessionOptions">The <see cref="ASWebAuthenticationSessionOptions"/> specifying the configuration for the ASWebAuthenticationSession.</param>
 /// <example>
 /// If any custom browser configuration is needed (e.g. using <see cref="ASWebAuthenticationSessionOptions.PrefersEphemeralWebBrowserSession"/>),
 /// a new browser instance should be instantiated and passed to <see cref="Auth0ClientOptions.Browser"/>.
 /// <code>
 /// var client = new AuthClient(new AuthClientOptions
 /// {
 ///   Domain = "YOUR_DOMAIN",
 ///   ClientId = "YOUR_CLIENT_ID",
 ///   Browser = new ASWebAuthenticationSessionBrowser(
 ///     new ASWebAuthenticationSessionOptions
 ///     {
 ///       PrefersEphemeralWebBrowserSession = true
 ///     }
 ///   )
 /// });
 /// </code>
 /// </example>
 public ASWebAuthenticationSessionBrowser(ASWebAuthenticationSessionOptions sessionOptions = null)
 {
     SessionOptions = sessionOptions;
 }