Getting started with 1Password for your growing team, or refining your setup? Our Secured Success quickstart guide is for you.
Forum Discussion
teejay87
2 years agoNew Contributor
Retrieve password and OTP in a single CLI command
I'm trying to automate a VPN connection using 1password CLI.
I managed to make it work successfully by requesting password and OTP in two steps, but this is currently requiring two separate 1passw...
teejay87
2 years agoNew Contributor
Thanks Jacob!
That actually solved my problem, running both commands in a one-liner requires only one authentication, even if it is still a bit slower than a single command.
I struggled a bit to come up with a batch syntax to concatenate password and OTP, but finally succeded.
I'm leaving it here for the records, in case someone needed it:
setlocal enabledelayedexpansion
FOR /F "tokens=*" %%g IN ('op item get "VPN" --fields password^&op item get "VPN" --otp') do (SET PWD=!PWD!%%g)
You can then pass the %PWD%
variable to the VPN connection command, or everything else you need it for.