Skip to content

export tokens

Terminal window
holocron export tokens
holocron export tokens --from-env
holocron export tokens --only HOLOCRON_SENTRY_TOKEN
holocron export tokens HOLOCRON_SENTRY_TOKEN sentry.comlink

Writes each token a configured plugin takes as a NAME=value line, to import them into a credentials environment. The CLI cannot write to a 1Password Environment (op has no command that sets a variable), so the last step is the app: open the Environment, Import .env file, and choose the file this command wrote. The import reads the file line by line, so every token lands as its own variable (pasting the same text into one field does not).

Names after tokens (or --only <name>, repeated) export only those tokens; both together are one list. A token is named by its variable name (HOLOCRON_SENTRY_TOKEN), the vendor’s own name (SENTRY_AUTH_TOKEN) or its keyring entry (sentry.comlink); a name that matches nothing is refused, with the names there are. On a terminal it goes to the clipboard instead of the file, since a value is for pasting: for one token the clipboard holds the value alone, with no name and no line break (the name is printed in the list), and for several it holds NAME=value lines. Clear the clipboard afterwards; --file and a pipe still work as they do for the whole set. This is how to get one token out of the keyring without security find-generic-password.

An environment with variables you have not got yet

Section titled “An environment with variables you have not got yet”

--blank writes a name with no stored value as NAME="" instead of leaving it out, and lets --only name a variable that is no token at all (also written empty). NAME=value writes a setting as given (it is read from nowhere, so use it for a name or a flag, never a secret). --vendor-names writes a token under the vendor’s own name (SENTRY_AUTH_TOKEN, VERCEL_TOKEN, CLOUDFLARE_API_TOKEN) instead of the Holocron one, which is what a workflow reads. Import the file and every variable the environment needs exists: the ones the keyring had are filled, the rest are empty, ready to be filled in.

Terminal window
holocron export tokens --blank --vendor-names --file \
--only HOLOCRON_ADMIN_TOKEN --only HOLOCRON_ORG_TOKEN --only HOLOCRON_READ_TOKEN --only VERCEL_TOKEN \
--only HOLOCRON_RELEASE_TOKEN --only HOLOCRON_OP_SERVICE_ACCOUNT_TOKEN # and so on
holocron export tokens --file --only ENVIRONMENT=prod # a setting for the Sentinel environment

A name that no plugin configured in this directory lists is written empty with --blank, even when the keyring has a value under it: run it from a directory whose holocron.config has the plugins (the repo root has most).

The names are the ones the plugins list for doctor secrets --verify and doctor secrets --verify, so they are the names the Environment is expected to hold, except the ones a plugin marks optional because it only falls back to them (marked (optional) in the list, and not expected by doctor secrets --verify). Each value comes from the OS keyring. A name listed by two plugins is written once.

exported 16 of 18:
✓ HOLOCRON_ADMIN_TOKEN
✓ HOLOCRON_AXIOM_TOKEN
✓ HOLOCRON_CHECKLY_TOKEN
✓ HOLOCRON_CLOUDFLARE_TOKEN
...
✓ HOLOCRON_USER_SYNC_TOKEN
· HOLOCRON_DISCORD_WEBHOOK (optional)
wrote /path/to/repo/.holocron/.private/.credentials (readable only by you)
import it in the 1Password app: Developer, View Environments, the Environment, Import .env file
press Enter when the import is done and the file will be deleted:
deleted /path/to/repo/.holocron/.private/.credentials

One row per token, by name only: a green ✓ for each one written, a dim · for each one that was not found in the keyring or the environment (with (optional) after it when the plugin only falls back to that token), and a ✗ with the reason for each one left out for another cause (below). Written tokens come first, then the rest, and each group is in lexicographic order, so the list reads the same on every machine; the lines in the file are in that order too. The file’s instructions come after a blank line.

The file is plain text for as long as it exists, so it is kept as private and as short-lived as it can be:

  • Private. It is created with mode 0600 (readable and writable by you alone), and its mode is set again after the write so a loose umask cannot widen it.
  • Ignored by git. It is .holocron/.private/.credentials next to holocron.config (the directory is made when missing), and the command writes it only when git positively says the path is ignored, or that it is not in a repository at all. A path git would track, and one where git could not say, are refused, so it cannot be committed by accident. holocron sync adds the rule that ignores everything in .holocron/.private/ except its .gitkeep; a repo without it is told to run that. With --file the path is yours to keep out of git.
  • Not on Windows. The 0600 mode means nothing there (other users may read a file the directory’s ACL shares), so the command refuses to write the file and points at --copy and a pipe.
  • Never overwritten. If the file is already there the command stops and says so, and it never writes through a symlink. --force replaces it: the new file is written beside it first and swapped in with an atomic rename, so a replacement that cannot be written leaves the old file exactly as it was, and only then is the old file’s content overwritten with zeros so an earlier run’s tokens are not left recoverable. For that moment a .credentials.<random>.tmp sits next to it (in the private directory, so it is ignored too). A write that fails removes the file it had created a moment before.
  • Deleted when you are done. On a terminal it waits for you to press Enter after the import, then overwrites the file with zeros and removes it. Ctrl-C, a terminated process (SIGTERM), a closed terminal (SIGHUP), the input ending and an error while waiting all delete it too. It removes only the file it wrote (by device and inode, holding the file open meanwhile so its inode cannot be reused by another file), so a file another process swapped in, or another export’s file, is left alone and the command says so. It overwrites through that open file, never through the path, so a symlink put in the path’s place is not followed, and the file it wrote is zeroed even if the path no longer points at it. It says deleted only when the file is gone; when it cannot delete it, it says so, names the path and exits 1. With --keep, or when there is no terminal to ask on, it leaves the file and prints the path to delete.
  • Not read by the CLI. Unlike a repo-root .env, nothing reads .credentials, so a copy left behind is not a token source.

Overwriting before deleting is best effort: a journaling or copy-on-write filesystem and an SSD can keep older blocks that an overwrite does not reach. That is why the file is private and short-lived, and why this is for moving tokens once, not for storing them.

Locking the file with a password or the keyring

Section titled “Locking the file with a password or the keyring”

There is no encrypted form that would help. The point of the file is for 1Password to read it, and 1Password reads a plain .env; a file locked with a password or a key from the keyring would have to be unlocked back to plain text before the import, which is the exposure the lock was meant to prevent. The lock that matters is the one the tokens are moving into: once they are in the 1Password Environment they are encrypted at rest and behind Touch ID, and the file has done its job. If you want less on disk, the clipboard never touches disk, but pastes into a single field in some apps.

Where stdout is What happens
a terminal the lines go to the private file above, and nothing is printed
a pipe the lines are written to stdout: holocron export tokens | some-tool
a regular file refused (holocron export tokens > tokens.env): it would leave the tokens on disk with none of the protections above. Use --file

--copy puts the lines on the clipboard instead, with clipboardy (pbcopy, xclip or wl-copy, clip). Clear the clipboard after pasting. A multi-line paste lands in one field in some apps, which is why the file is the default.

Option Description
--from-env Also take a token that is set in the environment (HOLOCRON_<X>, then the vendor’s own name), and let it win over the keyring for that token.
--file [path] Write to this file (relative to the config’s directory; default .holocron/.private/.credentials), even when stdout is a pipe.
--copy Put the lines on the clipboard instead. Cannot be combined with --file.
--keep Leave the file in place after writing it.
--force Replace the file if it is already there.

Anything that makes the list incomplete is said, not hidden:

  • The OS keyring cannot be reached: the command fails, rather than reporting every token as not found.
  • A plugin cannot be loaded: its package is named with the first line of why, because the tokens it takes are not in the list. With every configured plugin unresolvable it stops with the same workspace error as the other commands that need the plugins.
  • Two plugins list the same variable under different keyring entries: the name is reported and not exported, because one variable cannot hold both.
  • A value dotenv cannot carry unchanged: a value with a space, quote, # or backslash is wrapped in the first of ', " and ` it does not contain, which is how a dotenv parser reads it back as written (dotenv has no escape for a quote or a backslash, so none is added), and a line break is written as \n inside double quotes. A value that fits none of these is not exported and is named, so you add it by hand instead of importing a different token.

The plugins are resolved from the directory of the config that was loaded, so --cwd finds the plugins installed there. A token is looked up the way the commands look it up: under the keyring entry stored for the active org first (axiom.theholocron, from new token axiom --org theholocron), then under the plain one (axiom). A token that is in neither place (a GitHub Actions secret cannot be read back) has to come from wherever you first got it.

0 when at least one token was written or none was found, 1 when it refused or could not write (a redirect to a file, Windows, git does not ignore the file or could not say, the file exists, the clipboard did not work, the keyring cannot be reached) or could not delete the file afterwards. It needs a holocron.config to know which plugins to ask, so run it in the repo.

Related: list tokens, doctor secrets, new token.