darrenjrobinson / 1Pwd

PowerShell Module for 1Password CLI
4 stars 0 forks source link

How to use with MFA enabled accounts? #4

Open bgawale opened 2 years ago

bgawale commented 2 years ago

Tried using the PS module with CLI v1.x and using an account that has MFA enabled. After entering all details correctly, when tried invoking command below - it results in an error

$account = Test-1PasswordCredentials -SignInAddress $1PSignInAddress -SignInAccount $1PSignInAccount -SecretKey $1PSecretKey -MasterPassword $1PMasterPassword

Error: Enter your six-digit authentication code: [ERROR] 2022/07/05 07:16:59 incorrect One-Time Password length. expected 6

Is there any workaround for this or does this meant to work only with accounts without MFA enabled?

darrenjrobinson commented 2 years ago

I haven't actually tried that. Looking at the documentation the process appears to be to "Select Biometric Unlock for 1Password CLI". But that is with CLI v2 and my wrapper is for v1. Give it a go and let me know.

https://developer.1password.com/docs/cli/get-started/#turn-on-biometric-unlock

Woznet commented 1 year ago

I found the MFA OTP issue can be worked around by simple executing the default op.exe account add command, this will prompt you for each of the necessary parameters including the MFA OTP 6 digit code should MFA be enabled.

I also discovered that in 1Pwd.psm1 on line 232 if ($accountList.count -gt 1) { should be switched to if ($accountList.count -ge 1) {, using "-ge" allows this if statement to be true when you have only 1 account registered.

darrenjrobinson commented 1 year ago

Thanks for that info @Woznet, much appreciated. I'll look into adding that to the ReadMe and also make the other update you mention.

Which version of the CLI are you using? I recently updated this module to support both CLI1 and CLI2. Looking at your command I'm thinking CLI2, but just looking to confirm.

Thanks again 🙏🏻

Woznet commented 1 year ago

CLI2, specifically 2.19.0