Class: Whoa::Authentication

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

Defined Under Namespace

Classes: AuthError

Constant Summary collapse

Url =
'https://www.google.com/accounts/ClientLogin'

Instance Method Summary collapse

Instance Method Details

#auth_tokenObject



24
25
26
# File 'lib/whoa/authentication.rb', line 24

def auth_token
  send_request.body.match(/^Auth=(.*)$/)[1]
end

#parametersObject



7
8
9
10
11
12
13
14
15
# File 'lib/whoa/authentication.rb', line 7

def parameters
  {
    'Email'       => Whoa.email,
    'Passwd'      => Whoa.password,
    'accountType' => 'GOOGLE',
    'service'     => 'analytics',
    'source'      => 'whoa-001'
  }
end

#send_requestObject



17
18
19
20
21
22
# File 'lib/whoa/authentication.rb', line 17

def send_request
  RestClient.post(Url, parameters) do |response|
    raise AuthError unless response.code == 200 
    response.return!
  end
end