onepasswordDetailsFields
uuid [vault-uuid [account-name]]
onepasswordDetailsFields
returns structured data from
1Password using the 1Password
CLI (op
).
uuid is passed to op get item <uuid>
, the output from op
is parsed as
JSON, and elements of details.fields
are returned as a map indexed by each
field's designation
. If there is no valid session in the environment, by
default you will be interactively prompted to sign in.
The output from op
is cached so calling onepasswordDetailsFields
multiple
times with the same uuid will only invoke op
once. If the optional
vault-uuid is supplied, it will be passed along to the op get
call, which
can significantly improve performance. If the optional account-name is
supplied, it will be passed along to the op get
call, which will help it look
in the right account, in case you have multiple accounts (eg. personal and work
accounts).
Example
{{ (onepasswordDetailsFields "<uuid>").password.value }}
{{ (onepasswordDetailsFields "<uuid>" "<vault-uuid>").password.value }}
{{ (onepasswordDetailsFields "<uuid>" "<vault-uuid>" "<account-name>").password.value }}
{{ (onepasswordDetailsFields "<uuid>" "" "<account-name>").password.value }}
Example
Given the output from op
:
{
"uuid": "<uuid>",
"details": {
"fields": [
{
"designation": "username",
"name": "username",
"type": "T",
"value": "exampleuser"
},
{
"designation": "password",
"name": "password",
"type": "P",
"value": "examplepassword"
}
]
}
}
the return value of onepasswordDetailsFields
will be the map:
{
"username": {
"designation": "username",
"name": "username",
"type": "T",
"value": "exampleuser"
},
"password": {
"designation": "password",
"name": "password",
"type": "P",
"value": "examplepassword"
}
}
Info
If you're using 1Password CLI 2.0, then
the structure of the data returned by the onepasswordDetailsFields
template function will be different and you will need to update your
templates.
Warning
The structure of the data returned will not be finalized until 1Password CLI 2.0 is released.