For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /api/angular-lynx/web-auth-session.md.

LynxWebAuthSession

Opens a sign-in page in the phone's sign-in sheet and returns the URL it redirects to. import { LynxWebAuthSession, WebAuthSessionError, type WebAuthSessionOptions, type WebAuthSessionErrorCode } from '@blotch/angular-lynx';

Sign in with a web page shows it in use.

Usage

const webAuth = inject(LynxWebAuthSession);

const callback = await webAuth.start({
  url: 'https://example.com/oauth/authorize?client_id=my-app&redirect_uri=com.example.myapp:/oauth',
  callbackScheme: 'com.example.myapp',
});
const code = new URL(callback).searchParams.get('code');

API

LynxWebAuthSession

@Injectable({ providedIn: 'root' })
class LynxWebAuthSession {}

Uses ASWebAuthenticationSession on iOS and a Custom Tab on Android. Only the apps --platform builds, with ng build or ng serve, have it; elsewhere, such as Lynx Explorer, the web preview and unit tests, start() rejects with unavailable.

LynxWebAuthSession.start()

start(options: WebAuthSessionOptions): Promise<string>;

Opens options.url and resolves with the whole URL the page redirects to on options.callbackScheme, query and fragment included. Rejects with a WebAuthSessionError. One session can be open at a time: starting another while one is open rejects with failed.

WebAuthSessionOptions

type WebAuthSessionOptions = {
  readonly url: string;
  readonly callbackScheme: string;
  readonly ephemeral?: boolean;
};
OptionDescription
urlThe page that starts the sign-in, such as a provider's authorize URL
callbackSchemeYour app's URL scheme, such as com.example.myapp. On Android it must also be in deepLinkSchemes in angular.json
ephemeraltrue signs in without the browser's sign-ins and keeps none afterwards. iOS only: Android's Custom Tabs always share Chrome's. Defaults to false

WebAuthSessionError

class WebAuthSessionError extends Error {
  readonly code: WebAuthSessionErrorCode;
}

type WebAuthSessionErrorCode = 'canceled' | 'unavailable' | 'failed';
codeWhen
canceledThe person closed the sheet or the tab, or, on iOS, said no when asked whether the app may use the site
unavailableThe host has no sign-in sheet
failedThe page couldn't be opened, or a sign-in was already open