Detecting if account is setup (but not logged in)

jamesdh
jamesdh
Community Member

So op effectively has two logins:
1. The initial login requiring the secret key and possibly 2FA. This establishes the account on the device.
2. The second login, only requiring the password. This actually does log you in.

I'm trying to setup some automation using Ansible, and all I want to do is detect if the op account is setup, but don't need the user actively logged in. But I can't seem to find any way to do that, so I end up having to prompt for the users credentials multiple times.

I have a make task that essentially does the following:
if ! op signin my ; then op signin ... fi

If no account is setup, it correctly enters the conditional, prompts for credentials, and signs in. But if an account is setup, it still prompts for the password. Is there no way to detect account status?


1Password Version: 7.6
Extension Version: Not Provided
OS Version: MacOS 10.15.6
Sync Type: 1Pass

Comments

  • jamesdh
    jamesdh
    Community Member

    Ok, I missed this before, but it appears the accounts array in ~/.op/config does in fact get cleared when using op signout --account my --forget. So if the config file doesn't exist or the accounts array within it is empty, that should indicate what I asked for.

  • felix_1p
    felix_1p
    1Password Alumni

    So if the config file doesn't exist or the accounts array within it is empty, that should indicate what I asked for.

    That's right. Ideally you wouldn't have to rely on the config file directly, but I guess that's the best you can do for now.

    The second login, only requiring the password. This actually does log you in.

    The initial login also logs you in. It's more like this: You have to provide all information the first time you login. You can omit certain information (email, Secret Key) if you have already logged in before.

This discussion has been closed.