Sign in with a web page
Google, GitHub, Apple and most other sign-in providers use OAuth or OpenID Connect: the person signs in on the provider's web page, which then redirects back with a code or a token. Lynx has no popups or redirects, so that page can't run inside your app. LynxWebAuthSession opens it in the phone's own sign-in sheet instead, and gives you the URL the page redirects back to.
Open the sign-in page
urlis the page that starts the sign-in, usually the provider's authorize URL.callbackSchemeis your app's own URL scheme. The session ends when the page redirects to any URL on it, such ascom.example.myapp:/oauth?code=…, andstart()resolves with that whole URL, query and fragment included.- Check a
stateyou made up yourself. Send a random one with the request and make sure the same one comes back, as above. It's how you know the redirect answers your own request, not one someone else started. For a code your app exchanges itself, also use PKCE where your provider supports it.
Set up the callback scheme
Pick a scheme only your app uses. Reversing your app ID, such as com.example.myapp, keeps it unique. Register the redirect URL with your provider exactly as you send it in redirect_uri.
On Android, the redirect opens your app like any other link, so add the scheme to deepLinkSchemes in angular.json:
iOS needs nothing: the sign-in sheet catches the redirect itself.
What people see
- On iOS, the system first asks whether your app may use the site to sign in. The sheet is Safari's, and shares its sign-ins, so someone already signed in to the provider in Safari only has to confirm.
- On Android, the page opens in a Custom Tab, Chrome's in-app browser, which shares Chrome's sign-ins. The redirect brings your app back and closes the tab.
To sign in without the browser's sign-ins, and leave nothing signed in afterwards, pass ephemeral: true. It only applies on iOS: Custom Tabs always share Chrome's.
When it doesn't return a URL
start() rejects with a WebAuthSessionError, whose code says why:
Treat canceled as the person changing their mind, not as an error.
Lynx Explorer and the web preview don't have the sign-in sheet, so there start() rejects with unavailable. Try sign-in on a simulator, emulator or phone with ng serve --platform ios or --platform android. To use it in your own native app, see Embed in a Native App.
