Skip to main content
Check whether a session is signed in and run scripted sign-in logic when it is not.

librettoAuthenticate()

librettoAuthenticate is the runtime helper for workflows that combine an auth profile with scripted sign-in logic.

Options

isSignedIn
(ctx: LibrettoWorkflowContext) => Promise<boolean> | boolean
required
Checks whether the current browser page is already signed in. Return true only when the workflow can safely continue.
signIn
(ctx: LibrettoWorkflowContext, credentials: Record<string, string>) => Promise<void> | void
required
Performs the sign-in flow when isSignedIn returns false.
credentials
Record<string, unknown>
Credential values to pass to signIn. In workflows, pass input.credentials from declared workflow credentials.
envPrefix
string
Optional environment variable prefix used only when credentials is omitted. Workflow code should normally pass input.credentials instead.

Return value

usedProfile
boolean
true when the initial isSignedIn check passed, meaning the saved profile was already signed in. false when Libretto ran the signIn step.

Example

After signIn runs, librettoAuthenticate calls isSignedIn again. If the session is still not signed in, it throws an error instead of letting the workflow continue in a logged-out state.
Pair librettoAuthenticate with authProfile: { name, refresh: true } when a successful sign-in should update the profile for future runs.