80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/webbynode/api_client.rb', line 80
def init_credentials(overwrite=false)
creds = if io.file_exists?(CREDENTIALS_FILE) and !overwrite
properties
else
email = overwrite[:email] if overwrite.is_a?(Hash) and overwrite[:email]
token = overwrite[:token] if overwrite.is_a?(Hash) and overwrite[:token]
io.log io.read_from_template("api_token") unless email and token
email ||= ask("Login email: ")
token ||= ask("API token: ")
response = self.class.post("/webbies", :body => { :email => email, :token => token })
if response.code == 401 or response.code == 411
raise Unauthorized, "You have provided the wrong credentials"
end
properties['email'] = email
properties['token'] = token
properties.save
puts
{ :email => email, :token => token }
end
end
|