Module: SparkApi::Configuration::OAuth2Configurable

Included in:
SparkApi::Client, SparkApi::Configuration
Defined in:
lib/spark_api/configuration/oauth2_configurable.rb

Instance Method Summary collapse

Instance Method Details

#convert_to_oauth2?Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
# File 'lib/spark_api/configuration/oauth2_configurable.rb', line 4

def convert_to_oauth2?
  (self.authentication_mode == SparkApi::Authentication::OAuth2 ||
   self.authentication_mode == SparkApi::Authentication::OpenId ||
   self.authentication_mode == SparkApi::Authentication::OpenIdOAuth2Hybrid) &&
    self.oauth2_provider.nil? 
end

#grant_uriObject



25
26
27
28
29
# File 'lib/spark_api/configuration/oauth2_configurable.rb', line 25

def grant_uri
  e = self.endpoint.gsub(/\/+$/,"")
  v = self.version.gsub(/\/+/,"/")
  "#{e}/#{v}/oauth2/grant"
end

#oauth2_enabled?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/spark_api/configuration/oauth2_configurable.rb', line 11

def oauth2_enabled?
  self.authentication_mode == SparkApi::Authentication::OAuth2
end

#oauthify!Object



15
16
17
18
19
20
21
22
23
# File 'lib/spark_api/configuration/oauth2_configurable.rb', line 15

def oauthify!
  self.oauth2_provider = SparkApi::Authentication::SimpleProvider.new(
    :access_uri    => grant_uri,
    :client_id     => self.api_key,
    :client_secret => self.api_secret,
    :authorization_uri => self.auth_endpoint,
    :redirect_uri  => self.callback
  )
end