Class: Authinator::AuthCodeExchanger

Inherits:
Object
  • Object
show all
Defined in:
lib/authinator/auth_code_exchanger.rb

Constant Summary collapse

STUB_SAMPLE_TOKEN =
{
  token: 'ya29.token',
  refresh_token: '1/refresh',
  expires_in: 3600,
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider, _client_options = {}) ⇒ AuthCodeExchanger



18
19
20
# File 'lib/authinator/auth_code_exchanger.rb', line 18

def initialize(provider, _client_options = {})
  @provider = provider
end

Instance Attribute Details

#providerObject (readonly)

Returns the value of attribute provider.



11
12
13
# File 'lib/authinator/auth_code_exchanger.rb', line 11

def provider
  @provider
end

Class Method Details

.valid_providersObject

attr_reader :client



14
15
16
# File 'lib/authinator/auth_code_exchanger.rb', line 14

def self.valid_providers
  Authinator.configuration.providers
end

Instance Method Details

#exchange(auth_code) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/authinator/auth_code_exchanger.rb', line 26

def exchange(auth_code)
  # auth_code = params[:code]
  return if auth_code.nil? || auth_code.empty?

  case @provider.name
  when :google
    exchange_with_google(auth_code)
  when :stub
    exchange_with_stub(auth_code)
  end
end

#site_token_urlObject



22
23
24
# File 'lib/authinator/auth_code_exchanger.rb', line 22

def site_token_url
  @provider.site + @provider.token_url
end