Module: GrapeSimpleAuth::Extension

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

Instance Method Summary collapse

Instance Method Details

#oauth2(*scopes) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/grape_simple_auth/extension.rb', line 4

def oauth2(*scopes)
  description = if respond_to?(:route_setting) # >= grape-0.10.0
    route_setting(:description) || route_setting(:description, {})
  else
    @last_description ||= {}
  end

  description[:auth] = { scopes: scopes }
  description[:authorizations] = { oauth2: scopes.map { |x| { scope: x } } }
end