Class: OpenAuth2::Provider::Google

Inherits:
Object
  • Object
show all
Defined in:
lib/open_auth2/provider/google.rb

Instance Method Summary collapse

Instance Method Details

#optionsObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/open_auth2/provider/google.rb', line 4

def options
  {
    :authorize_url  => 'https://accounts.google.com',
    :code_url       => 'https://accounts.google.com',
    :authorize_path => '/o/oauth2/auth',
    :redirect_uri   => 'http://localhost:9393/google/callback',
    :token_path     => '/o/oauth2/token',
    :endpoint       => 'https://www.googleapis.com'
  }
end

#parse(config, body) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/open_auth2/provider/google.rb', line 15

def parse(config, body)
  json                    = JSON.parse(body)
  config.access_token     = json['access_token']
  config.token_arrived_at = Time.now
  config.token_expires_at = Time.now+3600

  # google sends refresh_token when getting access_token, but not
  # when refreshing
  unless config.refresh_token
    config.refresh_token = json['refresh_token']
  end
end