Class: SparkApi::Authentication::OAuth2Impl::GrantTypeBase

Inherits:
Object
  • Object
show all
Defined in:
lib/spark_api/authentication/oauth2_impl/grant_type_base.rb

Constant Summary collapse

GRANT_TYPES =
[:authorization_code, :password, :refresh_token]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, provider, session) ⇒ GrantTypeBase

Returns a new instance of GrantTypeBase.



25
26
27
28
29
# File 'lib/spark_api/authentication/oauth2_impl/grant_type_base.rb', line 25

def initialize(client, provider, session)
  @client = client
  @provider = provider
  @session = session
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



24
25
26
# File 'lib/spark_api/authentication/oauth2_impl/grant_type_base.rb', line 24

def client
  @client
end

#providerObject (readonly)

Returns the value of attribute provider.



24
25
26
# File 'lib/spark_api/authentication/oauth2_impl/grant_type_base.rb', line 24

def provider
  @provider
end

#sessionObject (readonly)

Returns the value of attribute session.



24
25
26
# File 'lib/spark_api/authentication/oauth2_impl/grant_type_base.rb', line 24

def session
  @session
end

Class Method Details

.create(client, provider, session = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/spark_api/authentication/oauth2_impl/grant_type_base.rb', line 7

def self.create(client, provider, session=nil)
  granter = nil
  case provider.grant_type
  when :authorization_code
    granter = GrantTypeCode.new(client, provider, session)
  when :password
    granter = GrantTypePassword.new(client, provider, session)
  # This method should only be used internally to the library
  when :refresh_token
    granter = GrantTypeRefresh.new(client, provider, session)
  else
    raise ClientError, "Unsupported grant type [#{provider.grant_type}]"
  end
  SparkApi.logger.debug { "[oauth2] setup #{granter.class.name}" }
  granter
end

Instance Method Details

#authenticateObject



30
31
32
# File 'lib/spark_api/authentication/oauth2_impl/grant_type_base.rb', line 30

def authenticate
  
end

#refreshObject



34
35
36
# File 'lib/spark_api/authentication/oauth2_impl/grant_type_base.rb', line 34

def refresh
  
end