databasedotcom 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/databasedotcom/client.rb +8 -2
- data/lib/databasedotcom/version.rb +1 -1
- metadata +1 -1
@@ -84,10 +84,12 @@ module Databasedotcom
|
|
84
84
|
#
|
85
85
|
# Raises SalesForceError if an error occurs
|
86
86
|
def authenticate(options = nil)
|
87
|
-
if (options
|
87
|
+
if user_and_pass?(options)
|
88
88
|
req = Net::HTTP.new(self.host, 443)
|
89
89
|
req.use_ssl=true
|
90
|
-
|
90
|
+
user = self.username || options[:username]
|
91
|
+
pass = self.password || options[:password]
|
92
|
+
path = "/services/oauth2/token?grant_type=password&client_id=#{self.client_id}&client_secret=#{client_secret}&username=#{user}&password=#{pass}"
|
91
93
|
log_request("https://#{self.host}/#{path}")
|
92
94
|
result = req.post(path, "")
|
93
95
|
log_response(result)
|
@@ -417,5 +419,9 @@ module Databasedotcom
|
|
417
419
|
def key_from_label(label)
|
418
420
|
label.gsub(' ', '_')
|
419
421
|
end
|
422
|
+
|
423
|
+
def user_and_pass?(options)
|
424
|
+
(self.username && self.password) || (options && options[:username] && options[:password])
|
425
|
+
end
|
420
426
|
end
|
421
427
|
end
|