Sha256: 1ad5268f59f5d10c7089a560383eb383b5d12f0e7f207dfb0d770b18711f3f3b
Contents?: true
Size: 1.1 KB
Versions: 13
Compression:
Stored size: 1.1 KB
Contents
require 'highline' require 'engineyard/api' module EY class CLI class API < EY::API def initialize(token = nil) @token = token if ENV['ENGINEYARD_API_TOKEN'] @token = ENV['ENGINEYARD_API_TOKEN'] end @token ||= EY::EYRC.load.api_token @token ||= self.class.fetch_token raise EY::Error, "Sorry, we couldn't get your API token." unless @token end def request(*) begin super rescue EY::API::InvalidCredentials EY.ui.warn "Credentials rejected; please authenticate again." refresh retry end end def refresh @token = self.class.fetch_token end def self.fetch_token EY.ui.info("We need to fetch your API token; please log in.") begin email = EY.ui.ask("Email: ") password = EY.ui.ask("Password: ", true) super(email, password) rescue EY::API::InvalidCredentials EY.ui.warn "Invalid username or password; please try again." retry end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems