Using PrefersEphemeralWebBrowserSession in Auth0 MAUI SDK
Last Updated:
Overview
This article explains why it is no longer possible to create ASWebAuthenticationSessionBrowser in MAUI SDK and a potential alternative. This can be used for suppressing the iOS consent prompt by setting Setting PrefersEphemeralWebBrowserSession = true.
Applies To
- Auth0 MAUI SDK
Cause
Solution
Instead, create a custom Browser implementation that is a copy of: Then replace:
var result = await WebAuthenticator.Default.AuthenticateAsync(new Uri(options.StartUrl), new Uri(options.EndUrl));With:
var result = await WebAuthenticator.Default.AuthenticateAsync(new WebAuthenticatorOptions { Url = new Uri(options.StartUrl), CallbackUrl = new Uri(options.EndUrl), PrefersEphemeralWebBrowserSession = true });
Then, when instantiating the client, pass the custom browser class that was created:
new Auth0Client() { Browser = new CustomBrowser() }