Skip to content

Instantly share code, notes, and snippets.

@tommorris
Last active November 2, 2018 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommorris/a6adca9bfa3818492861afb1789e73c4 to your computer and use it in GitHub Desktop.
Save tommorris/a6adca9bfa3818492861afb1789e73c4 to your computer and use it in GitHub Desktop.
An example of how to retrieve API keys from 1Password vault
eval $(op signin <yoursubdomain>) # this will prompt you to log in
export NEXMO_API_KEY=$(op get item Nexmo | jq '.details.sections[]? | select(.fields) | .fields[] | select(.t == "key").v')
export NEXMO_API_SECRET=$(op get item Nexmo | jq '.details.sections[]? | select(.fields) | .fields[] | select(.t == "secret").v')
@tommorris
Copy link
Author

screenshot 2018-11-02 at 15 42 13

You need a 1Password entry like this with your API key/secret stored in it.

You also need op (the 1Password CLI) set up, as well as jq. You may need to mess around with the jq selectors depending on how your API key/secret are stored.

The script above: pop it in a bash script, make sure it is in your path. When you call it, it'll ask you for your 1P passphrase and then set environment variables as appropriate from your vault. If you've got multiple credentials for a particular service, you should give them nice distinctive names.

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