Last active
February 3, 2025 11:25
-
-
Save Integralist/5010e113ce19285698cfe5d941b9884b to your computer and use it in GitHub Desktop.
[1Password CLI Usage] #1Password #op #cli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# list all accounts | |
op account list | |
# check which account we're using | |
op whoami | |
# switch account | |
op signin | |
op signin --account my # account flag must be passed subset of the URL from `op account list` (e.g. `my` matches `my.1password.com`) | |
# list all vaults | |
op vault list --format json | |
# list all items within the "Private" vault | |
op item list --vault "Private" --format json | |
# get a specific item from the "Private" vault | |
op item get "Your Item Title" --vault "Private" --format json | |
# get the password from a specific item from the "Private" vault | |
op item get "Your Item Title" --vault "Private" --fields password --reveal | |
# use 1Password "secret reference" wherever you need a secret to be used. | |
# e.g. an application config file or even an environment variable exported as part of a shell script. | |
# | |
# format: | |
# op://<VAULT_NAME>/<ITEM_NAME>/<FIELD> | |
# | |
# you can easily get the reference to any field using the 1Password GUI. | |
op read "op://Private/Fastly API Tokens/Integralist-PersonalAllServices/Token" | |
op inject -i some_input_file.tpl -o the_output_file_with_secret | |
export FASTLY_API_TOKEN=$(op read "op://Private/Fastly API Tokens/Integralist-PersonalAllServices/Token") | |
export FASTLY_API_TOKEN=$(echo "op://Private/Fastly API Tokens/Integralist-PersonalAllServices/Token" | op inject) | |
curl -sX GET "https://api.cloudflare.com/client/v4/user/tokens/verify" -H "Authorization: Bearer $(op read 'op://Private/6bky6ykumav2wfpguwn4dokcku/API Token')" -H "Content-Type:application/json" | jq | |
curl -sX GET "https://api.cloudflare.com/client/v4/user/tokens/verify" -H "Authorization: Bearer $(echo 'op://Private/6bky6ykumav2wfpguwn4dokcku/API Token' | op inject)" -H "Content-Type:application/json" | jq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment