AT Protocol spaces are in development. Expect changes throughout the beta starting on December 1st, 2026.

Chapter 9

OAuth and consent

Revised 2026-11-23Markdown

An app gets access to a person’s spaces through OAuth, which makes OAuth a practical requirement for any app that works with spaces. On the consent screen, the person is asked which spaces the app may reach (by authority, type, and key), what it may do to their records (action and collection), and whether it may manage the spaces themselves (manage). All of that is carried by the space: scope. The app has to scope it carefully. Asking for too little cuts the app off from what it needs, and asking for too much puts both the app and the person at risk.

Consider a session upgrade checkpoint for the parts of your app that need more. A person signs in with a general set of space: permissions for everyday use. When they open an admin or moderation area, the app asks them to authenticate again with the expanded permissions those tools need. The clean way to do this is to treat the upgraded session as a separate app with its own client_id, so the person and the app can both tell the two sessions apart and track each one.

Grammar#

Reference

The space: scope spec#

Ruth’s session holds space:com.example.familyUpdates?authority=*.

Text
space:<spaceType>
  [?authority=<did>|self|*]
  [&skey=<skey>|*]
  [&collection=<nsid>|*]...
  [&action=read_self|read|create|update|delete]...
  [&manage=create|update|delete]...

Shown wrapped; a real scope is one token spec.

Table 9.1 · Scope parameters and their defaults#
ParameterMultipleDefault
spaceTypenorequired; an NSID or *
authoritynoself, the granting user’s own DID
skeyno*
collectionyesthe type declaration’s collections
actionyesread, create, update, delete
manageyesnone

The type may also be given as a named parameter, space?spaceType=com.example.familyUpdates&authority=*, but not both ways in one scope. atproto-oauth accepts both forms crates.

The authority=self default is the important one. A bare space:com.example.bookmarks covers only the user’s own bookmarks space. The family app reads a space anchored on Marcus’s identity, so for everyone but Marcus it must say authority=* or name the authority spec.

Read is all-or-nothing#

The read action is what lets an app read other members' repos, because it grants getDelegationToken along with the read and sync methods on the user’s own PDS. It applies to every repo in the matching spaces and ignores collection. read_self is the narrower option, with the same read methods for the user’s own repo only and no delegation token. Granting read also grants read_self spec.

There is no per-collection or per-author read grant. A credential reads the whole space, so a narrower OAuth grant couldn’t be enforced anyway.

Writes and management#

create, update, and delete act on specific records and are constrained by collection. With collection omitted, they cover the type’s declared collections, resolved when the grant is evaluated, not frozen at consent. When the lexicon author adds a collection, existing bare grants widen to include it once caches turn over. An app that wants a fixed set lists collections explicitly. With spaceType=*, a grant has no type declaration to fall back on, so its writes reach only the collections it lists spec.

That widening is intentional. A space type that expects many collections can lean on the default, so its space: scopes stay short instead of naming every collection, and apps pick up new collections as the type grows without asking people to consent again. The trade-off is that the lexicon author, not the person who consented, decides how far a bare grant reaches.

The type’s collection list is a default, not a limit. A scope with no collection gets exactly the listed collections, so a bare grant on a type that lists com.example.foo lets an app write com.example.foo records and nothing else. A scope that names com.example.bar explicitly lets the app write those records too, even though the type doesn’t list them.

Applications can support space management features through the manage attribute of the space: scope, which covers the spaces themselves rather than the records in them spec. Each value authorizes a set of methods:

Table 9.2 · Space management grants#
manageAuthorizes
createcreateSpace for that type, usually with skey=*
updateupdateSpace, removeWriter under every policy, and each policy’s administrative methods, such as memberspace putMembers and removeMembers
deletedeleteSpace
create and updateimportSpaceMeta

Migrating records is the one place the two kinds of grant meet: importRepo needs the record action create on every collection in the archive.

A manage grant covers the space type as a whole. No parameter narrows it to particular policies, so an app holding manage=create or manage=update can create or update a space under any policy spec.

The power and scope of the manage field is intentional and by design. There are no finer-grained management permissions, and the risk is real. An app holding manage=update could let a person make a space public by accident, switch its policy type and lose its member list, or take other harmful and destructive actions. That’s the case for the step-up sessions described under If you’re building an app, so management grants aren’t used casually. It’s also a case for confirmation or two-factor steps in the app. A space owner’s PDS or space host should be able to lock or disable some kinds of management action, or at least notify the owner when one happens.

Write methods accept only OAuth, since writes are attributed to the user. Read and sync methods accept either a covering OAuth scope or a space credential spec.

Worked scopes#

Reference

The family app’s session scopes#

SessionScopesGrants
Marcusspace:com.example.familyUpdates?manage=create&manage=updateCreate and update his own family updates spaces and manage their members, plus full read and writes to the declared collections
Elenaspace:com.example.familyUpdates?authority=* and blob:image/*The same reads and writes in every family updates space she’s in, plus image uploads
Ruth, Nora, and Jakespace:com.example.familyUpdates?authority=*Elena’s grant without uploads

Each session also holds the base atproto scope. Marcus’s scope leaves out authority, so it covers only spaces he’s the authority of. Without manage=delete, this session can’t delete them.

A few other shapes cover cases the family app doesn’t need:

Table 9.3 · Worked space scopes#
ScopeGrants
space:com.example.bookmarksOwn bookmarks: read and write declared collections
space:com.example.familyUpdates?authority=*&action=readSame, read only
space:com.example.familyUpdates?authority=*&action=read_selfOwn records only, as for a backup tool
space:com.example.familyUpdates?authority=*&collection=*Full read, write any collection
space:com.example.familyUpdates?authority=did:plc:ejjl2znzqp3ci25dqaslpkk2&skey=our-family&collection=community.lexicon.calendar.rsvp&action=create&action=updateCreate and update RSVPs in the family space
space:com.example.familyUpdates?authority=*&action=read_self&manage=update&manage=deleteAdminister own family updates spaces, no record writes
space:*?authority=did:plc:ejjl2znzqp3ci25dqaslpkk2Read every space under one authority

Permission sets#

Applications are encouraged to use permission sets whenever possible, because they make for a much better user experience. A permission set describes what the app is asking for in friendlier wording, which is often clearer and easier to read than the raw scopes. The family app publishes com.example.authFamilyMember for its members and requests it as include:com.example.authFamilyMember:

JSON#
{
  "type": "permission-set",
  "title": "Family updates",
  "detail": "Read your family's updates and post your own",
  "permissions": [
    {
      "type": "permission",
      "resource": "space",
      "spaceType": "com.example.familyUpdates",
      "authority": "*",
      "action": [
        "read",
        "create",
        "update",
        "delete"
      ]
    }
  ]
}

Inside a permission set, spaceType must name a concrete type that follows the set’s namespace-authority rules. authority and collection can still be wildcards, and collection can name NSIDs from other namespaces. A grant for every space type, written as spaceType=*, works only as a standalone scope spec. A space: scope names one space type, so an app that works with spaces in syzygy asks for one scope for each type, with the same skey in each, and a permission set can bundle them when the types fall under its namespace.

When Elena signs in to the family app, the OAuth consent screen leads with the permission set’s own words: "Family updates: Read your family’s updates and post your own" crates. Under that, each space permission names its type by the type declaration’s title ("Family updates"), localized with title:lang, and falls back to the NSID when there’s no title. A named authority appears as its handle when the handle verifies in both directions, and as its DID otherwise, and self needs no label spec.

The screen saves its loudest warning for a scope with wildcards in both authority and spaceType, which reaches every space of every type spec. The family set names a concrete type, so even with authority set to *, Elena sees no warning.

Common questions#

Why can’t my app ask to read just one collection?#

A credential reads the whole space, so a narrower read grant couldn’t be enforced. Writes are different, and collection narrows them.

Why doesn’t my scope cover other people’s spaces?#

The authority parameter defaults to the user’s own identity. An app that reads spaces run by someone else asks for authority=* or names the authority.

Do users approve again when a space type adds a collection?#

Existing sessions pick up the new collection on their own. A bare grant resolves the type’s collections each time it’s checked, so the change takes effect once caches refresh.

Chapter 9 of 11 · AT Protocol Spaces: A Field Guide

Search