Class: Analytics::OAuth2

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

Class Method Summary collapse

Class Method Details

.access_token(token, opts = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/analytics/oauth2.rb', line 16

def access_token(token, opts = {})
  if token.nil?
    raise Analytics::Error::NoAccessTokenProvided
  elsif token.is_a? ::OAuth2::AccessToken
    token
  else
    ::OAuth2::AccessToken.new(oauth_client, token, opts)
  end
end

.oauth_clientObject



6
7
8
9
10
11
12
13
14
# File 'lib/analytics/oauth2.rb', line 6

def oauth_client
  @oauth_client ||= ::OAuth2::Client.new(
    Analytics.consumer_key, 
    Analytics.consumer_secret,
    :site => 'https://accounts.google.com',
    :authorize_url => '/o/oauth2/auth',
    :token_url => '/o/oauth2/token'
  )
end