mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 07:08:01 +00:00
Add Access 1Password Credential From CLI as a Workflow TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1413 TILs and counting..._
|
||||
_1414 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -1638,6 +1638,7 @@ _1413 TILs and counting..._
|
||||
### Workflow
|
||||
|
||||
- [Add Subtitles To Existing Mux Video Asset](workflow/add-subtitles-to-existing-mux-video-asset.md)
|
||||
- [Access 1Password Credential From CLI](workflow/access-1password-credential-from-cli.md)
|
||||
- [Change Window Name In iTerm](workflow/change-window-name-in-iterm.md)
|
||||
- [Convert An ePub Document To PDF On Mac](workflow/convert-an-epub-document-to-pdf-on-mac.md)
|
||||
- [Create A Local Sanity Dataset Backup](workflow/create-a-local-sanity-dataset-backup.md)
|
||||
|
||||
29
workflow/access-1password-credential-from-cli.md
Normal file
29
workflow/access-1password-credential-from-cli.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Access 1Password Credential From CLI
|
||||
|
||||
With the `op` CLI, I can store things like API keys and secrets in my 1Password
|
||||
vault and then access them from the command line. This assumes I've already
|
||||
installed the CLI (`brew install 1password-cli`) and connected it to the
|
||||
1Password app via the _Developer_ settings.
|
||||
|
||||
The `op item get` command takes a credential name and returns all the details
|
||||
for the entry with that _Title_. Here is how I can access my _Anthropic Claude
|
||||
API Key_ details.
|
||||
|
||||
```bash
|
||||
$ op item get "Anthropic Claude API Key"
|
||||
```
|
||||
|
||||
With the `--field` flag, I can grab a specific field, such as the `credential`,
|
||||
from that entry.
|
||||
|
||||
```bash
|
||||
$ op item get "Anthropic Claude API Key" --field credential
|
||||
sk-ant-api03-abc......xyz
|
||||
```
|
||||
|
||||
A command like this can be embedded in other commands as a way of referencing
|
||||
secrets without explicitly entering them into your shell history.
|
||||
|
||||
```bash
|
||||
$ curl https://api -H "x-api-key: $(op item get "Anthropic Claude API Key" --field credential)" ...
|
||||
```
|
||||
Reference in New Issue
Block a user