def self.authorize_credentials(options = {})
print 'Enter your username: ' if options[:username].nil?
username = options[:username] || gets.chomp
print 'Enter your password (not saved): ' if options[:password].nil?
password = options[:password] || STDIN.noecho(&:gets).chomp
parameters = { params: JSON_PARAMS.dup, username: username, password: password }
response = authorize(parameters)
if valid_credentials(response.code)
path = DEFAULT_NETRC
path = File.expand_path(options[:path]) if options[:path]
json = JSON.parse(response.body)
digits = json['result']
token = Pinup::Settings.token(username, digits)
options[:path] = path
options[:token] = token
Pinup::Settings.save_token(options)
return true
else
return nil
end
end