Skip to content

Instantly share code, notes, and snippets.

@dtaivpp
Created September 5, 2025 15:17
Show Gist options
  • Save dtaivpp/f0b9a956fe2e988d9e51763497aefbd8 to your computer and use it in GitHub Desktop.
Save dtaivpp/f0b9a956fe2e988d9e51763497aefbd8 to your computer and use it in GitHub Desktop.
A quick how-to create and access secrets using the 1Password CLI

A quick how-to create and access secrets using the 1Password CLI:

Install:

brew install 1password-cli

Create new vault:

op vault create CLI

Upload Secret:

op item create \
 --vault "CLI" \
 --category "API Credential" \
 --title "GH_Token" \
         "gh.GITHUB_TOKEN[password]=ghp_xyz"

Create the .env:

export GITHUB_TOKEN=$(op read "op://CLI/GH_Token/GITHUB_TOKEN")

Source the .env:

source .env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment