Module: OauthBwergemn::Extension

Extended by:
Extension
Included in:
Extension
Defined in:
lib/oauth_bwergemn/extension.rb

Instance Method Summary collapse

Instance Method Details

#oauth2(*scopes) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/oauth_bwergemn/extension.rb', line 5

def oauth2(*scopes)
  scopes = Doorkeeper.configuration.default_scopes.all if scopes.all? { |x| x.nil? }
  if respond_to?(:route_setting) # >= grape-0.10.0
    description = route_setting(:description) || route_setting(:description, {})
  else
    description = @last_description ||= {}
  end
  # case WineBouncer.configuration.auth_strategy
  # when :default
  description[:auth] = { scopes: scopes }
  # when :swagger
  description[:authorizations] = { oauth2: scopes.map { |x| { scope: x } } }
  # end
end