You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multi-token / multi-account handling in the CLI #1297
The CLI holds a single API token at a time (one account), stored in auth.json and the OS keyring. Switching accounts or organizations means running apify logout then apify login again; there is no way to keep multiple tokens registered or switch between them.
Goal
Let the CLI store multiple accounts under named profiles and switch the active one without re-authenticating. Commands run against the selected account.
Open questions
Profile model, and how the active profile is selected (default profile?). -> Stage-3
Selection surface: a per-command --account flag, an apify auth use <name> command, an env var, or a mix. -> Stage-3
Storage: extend auth.json and the keyring to hold multiple entries. -> Stage-1
Backward compatibility with existing apify login and logout. -> Stage-1 or Stage-3
Audit the auth test coverage before we start moving code. Fill only the gaps that protect
code we are keeping.
Known gaps to confirm:
getLoggedClient writes the keyring token, the proxy password and auth.json on every
command; none of that is asserted
logout has one test and checks the exit code only — nothing verifies the secret is gone
resolveToken has no tests, so current APIFY_TOKEN behaviour is not pinned
proxy password reaching the apify run child env is untested
the bundle keyring path (__APIFY_KEYRING_NATIVE_SUBPACKAGE__) has no smoke test
Stage-1: Auth storage v2 and token resolution #1383
Rewrite the auth layer so it can hold more than one account. No user-visible change — no new
flags, no new commands. Each subtask is releasable on its own, in this order:
Token resolutionToken resolution #1418 — one resolver instead of three. Precedence --token → APIFY_TOKEN → stored, and only apify login writes credentials
auth.json v2auth.json v2 #1419 — profiles keyed by user ID, field trim, migration of the three
states in the wild
Secret storage v2Secret storage v2 #1420 — per-profile keys in the keyring and in the file backend
Compatibility: after #1419 an older CLI reads the new file, finds no token and reports that
you are logged out. Changelog note needed; the migration writes auth.json.v1.bak.
Stage-2: Login - token multi account support #1386
Make apify login additive, so a second account can be stored at all.
login adds or updates a profile keyed by user ID; the new account becomes active
the profile name comes from the token, the username from user('me')
logout acts on the active profile, then switches to the most recently used one that remains
a user with a single account sees no change
Selecting between accounts is Stage-3, so until then a second account is reachable only by
logging in to it again. The Console browser flow inherits the additive behaviour but gets no
work — the device flow in #1328 replaces it.
APIFY_TOKEN still wins over everything, so --profile or auth switch together with it is an
error rather than a silent override. auth list, auth token and logout keep working.
Not here: renaming profiles, APIFY_PROFILE, an actor.json pin, and any change to mcp install.
Folding #445 in here as the single multi-account tracker. Carried over from it: the Notion "CLI auth v2" doc (linked in #445), the impersonate flag idea (apify push -i <org>), the AWS profiles precedent, and that #94 and #115 were already consolidated there.
Activity
patrikbraborec commentedon Sep 8, 2026
Folding #445 in here as the single multi-account tracker. Carried over from it: the Notion "CLI auth v2" doc (linked in #445), the impersonate flag idea (
apify push -i <org>), the AWS profiles precedent, and that #94 and #115 were already consolidated there.test: pin auth behavior before the multi-account refactor (#1417)
feat: make token login additive across accounts (#1458)
feat: add --profile, auth switch, auth list and per-account logout (#…
auth.jsonand unkeyed keyring migration paths #1480--api-urlon login #1486