---
title: "Provider accounts · OAuth sign-in (continued)"
description: "Provider accounts · OAuth sign-in (continued) from the built-in skills in Executor 2.0.0-beta.79."
---

This page covers OAuth sign-in from the [built-in skills](/docs/reference/skills) shipped with Executor `2.0.0-beta.79`. It contains `app-authoring/accounts.md`.

Previous: [Provider accounts · OAuth sign-in](/docs/reference/skills/app-authoring/accounts-3)

## OAuth sign-in

- `list` (no `requirement`) lists the scope's links.
- `get` lists a requirement's linked accounts, then the other accounts of its
  provider the caller could link.
- `link` links an account to the requirement, `unlink` removes the link and
  keeps the account.
- `connect` connects a new account, as above.

For a plain requirement, linking another account replaces the one before; the
previous account stays saved. For `.many()`, linking adds one. Linking fails
with `RequirementMismatch` when the app has no such requirement in that scope or
the account's provider differs. App links need edit access to the app and, to
link, use of the account. The same account may be linked in both scopes. An
account linked to an app for everyone cannot be deleted until it is unlinked
(`AccountLinkedToApp`).

An app whose requirement has no linked account exposes no tools. Connect or
link the account, then start a new execution to discover or call its tools.

An account has `id`, `method`, and typed `fields` inside app code. It exists
independently of the app and can be linked to several apps with the same
normalized provider definition. Changing that definition can change its provider
ID and account compatibility. Owner values are lookup metadata, not access
control; the current local bearer key allows access to the entire local instance.

## Two accounts and multiple tools

Calls never choose accounts. A plain user requirement uses the one account the
caller linked to it, and an app requirement the account linked for everyone; a
call that passes `$accounts` fails with `AccountChoiceUnsupported`, and one with
no account fails with `AccountRequired`, which says whether to link one or ask
someone who can edit the app to link one. Linking a second account to that
requirement replaces the first.

To use two accounts of one provider side by side, either declare a collection
slot or use two apps. A collection slot,
`const requirements = { user: { accounts: { mailboxes: gmail.many() } } }`, uses
every linked mailbox; in app code, `ctx.user.accounts.mailboxes` is an array,
empty when none is linked. `.many()` works under `app` too, with every account
linked for everyone.
To use fewer, unlink some. Two apps come from `apps.copy`: each is independent, with
its own source, Git history, links and an empty database.

Requirements apply to the whole app. A plain provider requires exactly one
account; optional single-account requirements are not implemented.

`defineApp(requirements, definition)` accepts a plain object for static declarations.
Each handler receives fresh accounts, traced fetch and cancellation in `ctx`.
External handlers can share types from a separate requirements module without
importing the final app. `AppContext<typeof requirements>` describes a handler's
context without its database session.

An async factory passed to `defineApp` runs afresh during inspection and calls.
It can return tools based on its accounts and upstream state. It also runs
without a caller for the app's background work, such as an app schedule, so its
`ctx.user` may be undefined: write `ctx.user?.accounts.service ?? []` for a
`.many()` requirement, or return no tools without a caller. Keep
writes inside tool handlers; do not register webhooks or perform mutations in
the factory. Build output retains code, not a permanent tool catalog.
