Protect what matters – even after you're gone. Make a plan for your digital legacy today.
Forum Discussion
Former Member
4 years ago[CLI2] `whoami` command with `--session` and `--account` errors out and ignores `--session`
Hi there!
I was using something like this to check whether a session was still valid for a specific account:
op whoami --session $SESSION --account $ACCOUNT
if [ $? = 0 ]
then
echo "Still valid"
else
echo "Not valid"
fi
I could swear this worked at some point, but now all I see is this error:
[ERROR] 2022/06/24 12:22:51 could not find session token for account $ACCOUNT
The whoami commands only seems to be working if I login using
eval $(op signin)
Once I do this, then the op whoami command above works, but it completely ignores the --session parameter:
$ op whoami --session foo --account $ACCOUNT
Shorthand: $ACCOUNT
URL: ...
Email: ...
User ID: ...
Could it be that there is a bug on the whoami command which is completely ignoring the --session cli parameter, and exclusively reading the token from the environmental variables?
CLI VERSION: 2.4.1
Thanks!
1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Browser:_ Not Provided
Referrer: forum-search:https://1password.community/search?Search=%5BCLI2%5D%20%60whoami%60%20command%20with%20%60--session%60%20and%20%60--account%60%20errors command with --session and --account errors
2 Replies
- Former Member
Hello Horia,
I've been debugging my scripts for quite a while but it seem to be a bug within the
op whoamicommand. Do you have any update for this?Currently this bugs means there is no way to determine if a user is already logged over CLI.
- Former Member
Hi @vitorqb , thank you for notifying us about this!
Indeed, it seems to be a bug, that
op whoamiignores the--sessionflag.
We have opened a ticket in our internal tracker, looking to get this fixed. We'll keep you updated with any developments related to this.Let us know if you have any more feedback for us!
Best,
Horia