Sha256: 5b084657c882a64e388e32f722325867aa38a62a18009d6031c37a6d7dc60062

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

# Copyright (C) 2013 Dmitry Yakimenko (detunized@gmail.com).
# Licensed under the terms of the MIT license. See LICENCE for details.

# Run via top level rake file:
# $ rake example

require "lastpass"
require "yaml"

DEVICE_ID = "example.rb"

credentials = YAML.load_file File.join File.dirname(__FILE__), "credentials.yaml"

username = credentials["username"]
password = credentials["password"]

begin
    # First try without a multifactor password
    vault = LastPass::Vault.open_remote username, password, nil, DEVICE_ID
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, DEVICE_ID
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, DEVICE_ID
end

vault.accounts.each_with_index do |i, index|
    puts "#{index + 1}: #{i.id} #{i.name} #{i.username} #{i.password} #{i.url} #{i.group}"
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lastpass-1.7.1 example/example.rb
lastpass-1.7.0 example/example.rb
lastpass-1.6.1 example/example.rb
lastpass-1.6.0 example/example.rb
lastpass-1.5.0 example/example.rb
lastpass-1.4.0 example/example.rb