Class: OauthDoorman::Api

Inherits:
Object
  • Object
show all
Includes:
AccessAPI, DomainGroupsAPI, OauthSender, UserInfoAPI
Defined in:
lib/oauth_doorman.rb

Constant Summary collapse

DEFAULT_CONFIG =
{
  :redirect_uri => "http://localhost:3000/oauth2callback",
  :client_id => "393121346607.apps.googleusercontent.com",
  :client_secret => "O1biKD-F1IX9h5t8LNQUFQk7",
  :scopes => ["https://www.googleapis.com/auth/userinfo.email", "https://apps-apis.google.com/a/feeds/groups/"],
  :auth_url => "https://accounts.google.com/o/oauth2/auth",
  :token_url => "https://accounts.google.com/o/oauth2/token",
  :response_type => "code",
  :state => "ATAXO",
  :user_info_url => "https://www.googleapis.com/oauth2/v1/userinfo",
  :groups_info_url => "https://apps-apis.google.com/a/feeds/group/2.0/%s/?member=%s",
  :groups_info_auth_header_name => "Authorization",
  :groups_info_auth_header_content => "OAuth %s",
  :groups_info_request_timeout => 5,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DomainGroupsAPI

#get_user_group_ids_from_xml, #get_user_groups

Methods included from Error

#process_error

Methods included from UserInfoAPI

#get_user_email, #get_user_info

Methods included from AccessAPI

#get_access_or_request_token, #get_access_token_from_refresh_token

Methods included from OauthSender

#compose_authentification_request_url

Constructor Details

#initialize(custom_config = nil) ⇒ Api

Returns a new instance of Api.



70
71
72
73
74
# File 'lib/oauth_doorman.rb', line 70

def initialize(custom_config = nil)
  if(custom_config)
    self.config = custom_config
  end
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



26
27
28
# File 'lib/oauth_doorman.rb', line 26

def access_token
  @access_token
end

#expires_inObject

Returns the value of attribute expires_in.



26
27
28
# File 'lib/oauth_doorman.rb', line 26

def expires_in
  @expires_in
end

#refresh_tokenObject

Returns the value of attribute refresh_token.



26
27
28
# File 'lib/oauth_doorman.rb', line 26

def refresh_token
  @refresh_token
end

#start_timeObject

Returns the value of attribute start_time.



26
27
28
# File 'lib/oauth_doorman.rb', line 26

def start_time
  @start_time
end

Instance Method Details

#configObject



49
50
51
# File 'lib/oauth_doorman.rb', line 49

def config
  return @config ||= DEFAULT_CONFIG
end

#config=(conf) ⇒ Object



45
46
47
# File 'lib/oauth_doorman.rb', line 45

def config= conf
  @config = DEFAULT_CONFIG.merge(conf)
end

#init_connection_by_code(code) ⇒ Object



76
77
78
# File 'lib/oauth_doorman.rb', line 76

def init_connection_by_code(code)
  init_connection(code, nil)
end

#init_connection_by_refresh_token(refresh_token) ⇒ Object



80
81
82
# File 'lib/oauth_doorman.rb', line 80

def init_connection_by_refresh_token(refresh_token)
  init_connection(nil, refresh_token)
end

#remaining_seconds_to_expirationObject



84
85
86
# File 'lib/oauth_doorman.rb', line 84

def remaining_seconds_to_expiration()
  return @expires_in - (Time.now - @start_time)
end