Skip to content

Commit 98cce08

Browse files
fix: use op whoami instead of op account list for auth check (#9)
op account list doesn't work with service account tokens (OP_SERVICE_ACCOUNT_TOKEN) — it returns non-zero because service accounts don't have "accounts" in the traditional sense. This causes op-exec to fail after a system restart when only the service account token is available. op whoami works with both interactive sessions and service account tokens, making it the correct auth check. Co-authored-by: jack-nsheaps[bot] <254347511+jack-nsheaps[bot]@users.noreply.github.com>
1 parent 53d8d1a commit 98cce08

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

bin/op-exec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,10 @@ main() {
197197
command -v op >/dev/null 2>&1 || fatal "1Password CLI (op) not found"
198198
command -v jq >/dev/null 2>&1 || fatal "jq not found"
199199

200-
# Check if signed in
201-
if ! op account list >/dev/null 2>&1; then
202-
fatal "Not signed in to 1Password. Run 'op signin' first."
200+
# Check if signed in (use whoami, not account list — account list
201+
# doesn't work with service account tokens)
202+
if ! op whoami >/dev/null 2>&1; then
203+
fatal "Not signed in to 1Password. Run 'op signin' first, or set OP_SERVICE_ACCOUNT_TOKEN."
203204
fi
204205

205206
# Parse reference

0 commit comments

Comments
 (0)