Class: GoogAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/rb_goog_auth.rb

Constant Summary collapse

@@AUTH_URL =
"https://www.google.com/accounts/ClientLogin"

Instance Method Summary collapse

Instance Method Details

#get_credentials(login_info) ⇒ Object

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rb_goog_auth.rb', line 8

def get_credentials()
  
  email = [:username]
  password = [:password]
  source = [:source]
  serv = [:service]
  
  raise ArgumentError if [email, password, source, serv].include? nil
  raise ArgumentError if [email, password, source, serv].include? ''

  response = Typhoeus::Request.post(@@AUTH_URL, :params => {'Email' => email, 'Passwd' => password, 'source' => source, 'service' => serv})
  
  return nil if response.code != 200
  
  to_return = {}
  
  response.body.split("\n").each do |l|
    next if l.strip.nil? or l.strip.length == 0
    k, v = l.strip.split("=")
    to_return[k] = v
  end
  
  return to_return
  
end