Teamwork Graph CLI (TWG CLI) uses OAuth 2.1 for personal sign-in. Bitbucket commands use a separate token. TWG CLI stores credentials under ~/.config/twg/ on macOS and Linux, or %APPDATA%\twg on Windows.
To learn how authentication works, see How authentication works.
In your terminal, run:
1 2twg login
TWG CLI displays a verification URL and short code and offers to open your browser. If it doesn't open, copy the URL and open it manually.
In your browser:
Return to your terminal and choose the profile's default site if prompted. A single accessible site is selected automatically; twg login --site <site> skips the picker. TWG CLI verifies the site's organization and confirms when your credentials are saved.
Login profiles are available in TWG CLI v1.3.6 and later. Use them to keep separate logins for different organizations. Each profile stores its own login, organization, default site, and optional Bitbucket token.
To sign in to another organization, create a named profile:
1 2 3twg login --new-profile work twg auth profile list
TWG allows one profile per organization. To replace an existing login, see Update or remove a profile.
You can also let TWG choose a name:
1 2twg login --new-profile
Profile names follow these rules:
hello-oauth. For .atlassian.net sites, TWG uses the site prefix. For other hostnames, it keeps the full hostname and replaces dots with hyphens.-2, -3, and so on to generated names. If you supply a name that already exists, TWG rejects it before sign-in starts.default is reserved, regardless of capitalization. You can't create or rename a profile to use it.Use the saved default profile and its default site:
1 2twg jira workitem get ABC-1
Choose a site and let TWG select the profile for that site's organization:
1 2twg jira workitem get ABC-1 --site personal-site
Choose both the site and the login:
1 2twg jira workitem get ABC-1 --site personal-site --profile personal
--profile personal keeps the command on that login. If the organization doesn't match or the account can't access the item, TWG returns an error without trying another login.--profile default selects the saved default profile, whatever its name.TWG_PROFILE=work in your shell to select work across commands. A command-line --profile personal overrides it. Both selectors keep the chosen login even when you supply --site.For the full selection order, see Login profiles.
twg auth profile default work.twg setup default-site --site <site>.Signing in again preserves the default. Choosing a profile for one command does not change the saved default.
To replace a profile's saved login credentials, run:
1 2twg login --profile work --force
To remove a profile and its credentials, run:
1 2twg logout --profile work
Your existing login keeps working after you upgrade:
--profile verifies that profile independently of other imported logins.TWG CLI can store encrypted credentials in auth-storage/auth.db. This experimental option keeps the root key separate: in the OS vault by default on macOS and Windows, or supplied through TWG_AUTH_STORAGE_KEY on any supported OS. This protects credentials from software that can read local files but cannot access the root key.
| Platform | Root key | Instructions |
|---|---|---|
| macOS | macOS Keychain by default; environment key optional | macOS |
| Windows | Windows Credential Manager by default; environment key optional | Windows |
| Linux | TWG_AUTH_STORAGE_KEY environment variable | Linux |
Encrypted storage uses macOS Keychain for the root key by default.
If you already use TWG CLI, migrate your existing credentials:
1 2twg auth storage migrate
The command asks before switching between file storage (auth-profiles.json) and encrypted storage (auth.db). It preserves credentials and defaults, including single-login auth.conf installations. Use --yes for an already-confirmed script.
If you are signing in for the first time, save the login directly to encrypted storage:
1 2TWG_SECRET_STORE=keychain twg login --force --oauth
TWG_SECRET_STORE only applies to login; it does not need to remain set.
Encrypted storage uses Windows Credential Manager for the root key by default.
In PowerShell, migrate existing credentials:
1 2twg auth storage migrate
If you are signing in for the first time:
1 2$env:TWG_SECRET_STORE = "keychain"; twg login --force --oauth
In Command Prompt, migrate existing credentials:
1 2twg auth storage migrate
If you are signing in for the first time:
1 2set TWG_SECRET_STORE=keychain && twg login --force --oauth
The setting applies only to the current shell session; you do not need to persist it.
Linux requires TWG_AUTH_STORAGE_KEY for each command. To migrate existing credentials:
1 2TWG_AUTH_STORAGE_KEY=<your-key> twg auth storage migrate
If you are signing in for the first time:
1 2TWG_SECRET_STORE=keychain TWG_AUTH_STORAGE_KEY=<your-key> twg login --force --oauth
Use an unpadded base64url encoding of a random 32-byte root key. Supply the same TWG_AUTH_STORAGE_KEY for every command that uses this database, on any supported OS. A new key cannot convert or unlock an OS-vault database. For example:
1 2TWG_AUTH_STORAGE_KEY=8XecAMpUKloUsQfQnmk_y0PEgOB4p4lIsvFjL1d0TT8
Generate and protect your own key; do not reuse this example.
To confirm which storage method is in use, run:
1 2twg doctor --basic
On macOS with encrypted storage enabled, the output includes:
1 2 3 4 5 6Connectivity Status: ok Token: valid Auth source: ~/.config/twg/auth-storage/auth.db (encrypted; root key in OS vault) Message: Authenticated successfully. OAuth token is valid for the configured endpoint.
The Auth source identifies the credential store and whether its root key comes from the OS vault or environment.
A coding agent using encrypted storage needs:
TWG_AUTH_STORAGE_KEY for environment-key storage.auth.db.Give the agent only the access it needs. Keep the root key and OAuth token out of prompts, chat, and command arguments; supply the key through the environment.
To refresh credentials outside the agent sandbox, enable OAuth upkeep:
1 2twg upkeep enable
twg setup enables upkeep automatically. The helper runs as your user and refreshes credentials in the background. It does not retain TWG_AUTH_STORAGE_KEY; refresh an environment-key database in a normal terminal with the same key. If an agent cannot access the config directory or OS vault, use twg doctor --basic or twg auth refresh in a normal terminal, or update its sandbox permissions.
For a fuller authentication and connectivity check, run:
1 2twg doctor
Add --site <site> or --profile <name> to check a particular login. Doctor reports the selected profile, storage path, and authentication method.
To sign in again:
1 2twg login
To restart sign-in and replace saved credentials:
1 2twg login --force
TWG CLI normally refreshes OAuth credentials before they expire. To check every profile without signing in:
1 2twg auth refresh
If the credentials are still fresh, the command makes no changes. Use --force only for manual repair or validation:
1 2twg auth refresh --force
Add --profile work or --profile default to refresh only that profile. Without the flag, refresh checks all profiles, even if TWG_PROFILE is set. A failed refresh does not stop the others.
Before refreshing, TWG CLI checks that it can save the updated credentials. If the config directory isn't writable, it sends no refresh request and asks you to run twg auth refresh in a normal terminal. It also detects common coding agents and prints the relevant configuration.
Upkeep is a per-user background helper that runs outside coding-agent sandboxes. It keeps OAuth credentials fresh and checks for CLI upgrades. twg setup enables it during installation. To enable or repair it later:
1 2twg upkeep enable
On macOS, you may see a system notification that software from Atlassian Pty Ltd or twg can run in the background. This is expected after twg setup enables the upkeep helper.
It does not install upgrades automatically. You can manage it in System Settings > General > Login Items & Extensions.
Every 12 minutes, upkeep checks OAuth credentials for all profiles. It checks for CLI upgrades at most once a day and sends limited reminders to run twg upgrade when one is available. It never downloads or installs upgrades automatically.
Use these commands to inspect, run, or remove it:
1 2 3 4twg upkeep status twg upkeep run twg upkeep disable
TWG CLI uses a macOS LaunchAgent, Linux systemd user timer, or Windows Scheduled Task to run the helper as your user.
On Linux, scheduling requires a systemd user instance and an active user D-Bus session. If setup cannot install the schedule, retry twg upkeep enable after fixing the reported system error.
Upkeep stores non-secret maintenance state in upkeep.json. It stays enabled after twg logout and checks any remaining profiles. twg uninstall disables it, attempts to revoke stored OAuth credentials, and removes the CLI and local TWG configs.
If you disable the helper, TWG CLI still works, but OAuth refresh and upgrade notifications may not run in the background. Run twg auth refresh or twg upgrade manually if needed.
Bitbucket commands require a separate token attached to your Atlassian login profile. Sign in first, then set it up with:
1 2twg setup bitbucket
twg setup also offers this during setup. A valid existing token is reused. If the token is invalid or expired, twg setup bitbucket starts token setup again automatically. Pass --force to replace a token without checking it first:
1 2twg setup bitbucket --force
Add --profile work to attach the token to a particular login.
For CI/CD, set the TWG_BBC_TOKEN environment variable to your Bitbucket token. If it is set when you replace a token through setup, update or unset it afterward because it overrides the saved token.
Rate this page: