Module: OAuthAdapter

Defined in:
lib/oauth_adapter.rb,
lib/oauth_adapter/config.rb,
lib/oauth_adapter/omniauth.rb

Defined Under Namespace

Modules: ProviderSaving Classes: Application, Configuration

Class Method Summary collapse

Class Method Details

.configObject



7
8
9
# File 'lib/oauth_adapter/config.rb', line 7

def config
  @config ||= Configuration.new
end

.configure(&block) ⇒ Object



3
4
5
# File 'lib/oauth_adapter/config.rb', line 3

def configure(&block)
  config.instance_eval(&block)
end

.get_access_token(provider:, token:, secret: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/oauth_adapter.rb', line 10

def get_access_token(provider:, token:, secret: nil)
  app = OAuthAdapter.providers[provider.to_sym]
  args = [app.client_id, app.client_secret, site: app.site]

  if secret.nil?
    client = OAuth2::Client.new(*args)
    OAuth2::AccessToken.new(client, token)
  else
    consumer = OAuth::Consumer.new(*args)
    OAuth::AccessToken.new(consumer, token, secret)
  end
end

.providersObject



6
7
8
# File 'lib/oauth_adapter.rb', line 6

def providers
  @providers ||= {}
end