Auth0 Home Blog Docs

[Swift] Embedding a browser-based auth0 login in a native application (WKWebView)

Hi all, I’m a true beginner in terms of SSO, Auth0 & co, so I really appreciate your patience and feedback.

This topic is related to the Browser-Based vs. Native Login Flows on Mobile Devices documentation page.

We want to try using the browser-based flow for two of our applications, given all the advantages listed in the documentation above. However, the current way the web page is presented is not acceptable on a UX/UI level for the following reasons:

  1. popup alert at every sign-in and logout attempt
  2. modal presentation of the view controller
  3. UI elements that are unwanted (browser settings, sharing…)

We were able to bypass 1) and 2) by using WebAuth.useLegacyAuthentication (uses SFSafariViewController instead of SFAuthenticationSession), but 3) is still an issue:

Auth0
    .webAuth()
    .useLegacyAuthentication()
    .scope("openid profile offline_access")
    .audience(url)
    .start(auth0LoginCallback)

Ideally, we would like to use a WKWebView in our applications that would load the browser-based login page, cleanly embedded in the rest of the native application. Is this possible?

Ty!