IS anyone using ASWebAuthenticationSession with matchesURL method?

I searched several times online for someone who is using the new ASWebAuthenticationSession init together with matchesURL but I haven't found any mention of it.

Is anyone using this new initializer? If so, can someone please share a code example? I'm trying to use the new initializer with a https redirect URL.

Thank you!

If you're adopting ASWebAuthenticationSession for signing in to your app, you shouldn't need to call matchesURL() (except maybe for debugging purposes). That method exists mainly for web browsers that implement handling of ASWebAuthenticationSession requests.

To use ASWebAuthenticationSession for signing in, you probably want something like

let session = ASWebAuthenticationSession(url: URL(string: "https://example.com/signIn")!, callback: .https(host: "mycoolsite.com", path: "/auth")) { callbackURL, error in
    guard let callbackURL else { ... }
    finishMySignIn(with: callbackURL)
}

session.presentationContextProvider = presentationContextProvider
session.start()

This will open "https://example.com/signIn" in a browser context, and watch for a redirect to a URL that starts with "https://mycoolsite.com/auth". When a page matching that URL gets loaded, you'll get the full URL in the callbackURL argument, which should have the necessary auth tokens.

Note that for custom schemes, there's no need to claim the scheme in your Info.plist. However for https callbacks, you must use Associated Domains with the webcredentials association to prove ownership of the website with the callback URL.

IS anyone using ASWebAuthenticationSession with matchesURL method?
 
 
Q