example/example.rb in lastpass-1.0.1 vs example/example.rb in lastpass-1.1.0

- old
+ new

@@ -10,10 +10,27 @@ credentials = YAML.load_file File.join File.dirname(__FILE__), "credentials.yaml" username = credentials["username"] password = credentials["password"] -vault = LastPass::Vault.open_remote username, password +begin + # First try without a multifactor password + vault = LastPass::Vault.open_remote username, password +rescue LastPass::LastPassIncorrectGoogleAuthenticatorCodeError => e + # Get the code + puts "Enter Google Authenticator code:" + multifactor_password = gets.chomp + # And now retry with the code + vault = LastPass::Vault.open_remote username, password, multifactor_password +rescue LastPass::LastPassIncorrectYubikeyPasswordError => e + # Get the password + puts "Enter Yubikey password:" + multifactor_password = gets.chomp + + # And now retry with the Yubikey password + vault = LastPass::Vault.open_remote username, password, multifactor_password +end + vault.accounts.each_with_index do |i, index| - puts "#{index + 1}: #{i.id} #{i.name} #{i.username} #{i.password} #{i.url} #{i.group}}" + puts "#{index + 1}: #{i.id} #{i.name} #{i.username} #{i.password} #{i.url} #{i.group}" end