class GrapeTokenAuth::OmniAuthCallBackRouterAPI

Upon a callback from the OmniAuth provider this API (endpoint) provides routing to the indvidual resource class's OmniAuthAPI callback endpoint. This API eventually gets mounted at /OMNIAUTH_PREFIX/ where OMNIAUTH prefix is configured in GrapeTokenAuth

Public Instance Methods

redirect_route_from_api(api, provider) click to toggle source
# File lib/grape_token_auth/apis/omniauth_api.rb, line 115
def redirect_route_from_api(api, provider)
  prefix = api.routes.find do |r|
    minor = /0\.(\d\d).\d+/.match(Grape::VERSION)[1].to_i
    path = minor >= 16 ? r.origin : r.path
    %r{/:provider/callback}.match(path)
  end.path.split(%r{/:provider})[0]
  Pathname.new(prefix).join(provider, 'callback.json').to_s
end
resource_class_from_auth() click to toggle source
# File lib/grape_token_auth/apis/omniauth_api.rb, line 124
def resource_class_from_auth
  scope = request.env.fetch('omniauth.params', {})['resource_class']
  return unless scope
  GrapeTokenAuth.configuration.scope_to_class(scope.underscore.to_sym)
end
session() click to toggle source
# File lib/grape_token_auth/apis/omniauth_api.rb, line 130
def session
  request.env['rack.session']
end