Module: Doorkeeper::GrantsAssertion::OmniAuth

Defined in:
lib/doorkeeper/grants_assertion/omniauth.rb

Class Method Summary collapse

Class Method Details

.oauth2_wrapper(provider:, strategy_class:, client_id:, client_secret:, client_options:, assertion:, expires_at: nil, expires_in: nil, refresh_token: nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/doorkeeper/grants_assertion/omniauth.rb', line 7

def oauth2_wrapper(
  provider:,
  strategy_class:,
  client_id:,
  client_secret:,
  client_options:,
  assertion:,
  expires_at: nil,
  expires_in: nil,
  refresh_token: nil
)
  app = nil # strategy_class is a rack middleware
  default_options = { name: provider }
  options = default_options.merge(client_options)
  args = [client_id, client_secret, options]
  wrapper = Class.new(strategy_class).new(app, *args)
  wrapper.access_token = OAuth2::AccessToken.new(
    wrapper.client,
    assertion,
    expires_at: expires_at,
    expires_in: expires_in,
    refresh_token: refresh_token
  )
  wrapper
end