Skip to main content

Service accounts

Give a script or a pipeline its own token, and cut it off without touching anyone else.

Prerequisites​

  • A running afe serve.
  • AFE_API_TOKEN set to the bootstrap token, or a single sign-on session of an administrator.

Steps​

  1. Create the account. The expiry is optional:

    afe service-account create ci-bot --expires 2027-06-30

    The command prints the token once, then a warning. Copy it now. The engine stores only a hash.

  2. Give the token to the script:

    export AFE_API_TOKEN=afe_sa_...
    afe run review --input input.yaml --url wss://afe.my-company.test/rpc

    Service account tokens start with afe_sa_. Every action the script takes is recorded under the account's name.

  3. List the accounts:

    afe service-account list

    The list shows the creator, the dates, and whether the account is revoked. It never shows tokens.

  4. Revoke the account when you no longer need it:

    afe service-account revoke ci-bot

    A new call with the token fails at once. An open connection is re-checked every 60 seconds and closes with code 4401, even when the client sends nothing.

A service account is never a global administrator. It has only the roles a project's access block gives it. Only a global administrator creates, lists or revokes accounts.

Troubleshooting​

error: set AFE_API_TOKEN to talk to a server. The variable is empty in this shell.

permission denied (-32008). The caller is not an administrator. Only a refused create or revoke leaves an entry in the audit trail: the other administrator methods only read.

An account name is rejected. The name already exists, revoked accounts included.

See also​