How to use service accounts and regular accounts in the same environment?
I noticed that you silently released Service Accounts little over a week ago in https://app-updates.agilebits.com/product_history/CLI2#v2180001 of 1Password CLI and naturally began testing it immediately (a blog post announcement would've been nice for this (eventually) useful feature).
My use case is to only use the Service Account for scheduled scripts that should run without any user interaction, but I want to still be able to use the CLI with my personal account on the same device at the same time. Based on my testing I quickly ran into an issue with this and I've not been able to find the solution for it in the https://developer.1password.com/docs/. I'm signed in to the desktop app with my Family Account and have had it connected to the CLI for years, and it's been working great. After following the instructions for setting up a Service Account, the CLI is always using the Service Account for all of the commands I execute.
I'll repeat the steps below for clarity.
- I ran
op user get --me
and it listed my personal account. - I ran
$Env:OP_SERVICE_ACCOUNT_TOKEN = "<your-service-account-token>"
and then ranop user get --me
and it listed the Service Account. - I ran some tests with a script I'm going to use the Service Account for and it worked as expected.
- I then tried to run
op item get "1Password University"
which is an item stored in my private vault, which the Service Account doesn't have access too (going for the principle of least privilege) and got the error[ERROR] 2023/05/25 19:47:41 a vault query must be provided when this command is called by a service account. Please specify one either through the --vault flag or through piped input
. - I tried using the flag
--account
to tell it to use my personal account for the command (op item get "1Password University" --account ABCDEFGHIJKLMNOPQRSTWXYZ
) which generated the same error. - I tried
op vault list
with and without theaccount
flag which generated the same result; a list of the vault that the Service Account has access to.
The only way I've found to get the op user get --me
command to show that I'm using my personal account again is to first run $Env:OP_SERVICE_ACCOUNT_TOKEN = ""
to set it to an empty string. This caused the CLI to require me to authenticate for the next command I ran, but it also means that the Service Account isn't authenticated or used anymore and any scheduled script which is using secret references will prompt me for authentication.
Am I missing something or is it simply not possible to use this according to my use case? Do I have to use a VM or something like that and set up 1Password CLI on that machine and run all scheduled scripts from that device?
1Password Version: 1Password for Windows 8.10.7 (81007011)
Extension Version: 2.11.1 21100100, on BETA channel
OS Version: Windows 10 22H2
Browser:_ Firefox 113.0.1 (64-bit)
Referrer: forum-search:https://1password.community/search?Search=using%20service%20accounts%20at%20the%20same%20time%20as%20a%20regular%20user