class Grape::OAuth2::Strategies::Base

Base Grape::OAuth2 Strategies class . Contains common functionality for all the descendants.

Public Class Methods

authenticate_client(request) click to toggle source

Authenticates Client from the request.

# File lib/grape_oauth2/strategies/base.rb, line 10
def authenticate_client(request)
  config.client_class.authenticate(request.client_id, request.try(:client_secret))
end
authenticate_resource_owner(client, request) click to toggle source

Authenticates Resource Owner from the request.

# File lib/grape_oauth2/strategies/base.rb, line 15
def authenticate_resource_owner(client, request)
  config.resource_owner_class.oauth_authenticate(client, request.username, request.password)
end
config() click to toggle source

Short getter for Grape::OAuth2 configuration

# File lib/grape_oauth2/strategies/base.rb, line 20
def config
  Grape::OAuth2.config
end
expose_to_bearer_token(token) click to toggle source

Exposes token object to Bearer token.

@param token [#to_bearer_token]

any object that responds to `to_bearer_token`

@return [Rack::OAuth2::AccessToken::Bearer]

bearer token instance
# File lib/grape_oauth2/strategies/base.rb, line 40
def expose_to_bearer_token(token)
  Rack::OAuth2::AccessToken::Bearer.new(token.to_bearer_token)
end
scopes_from(request) click to toggle source

Converts scopes from the request string. Separate them by the whitespace. @return [String] scopes string

# File lib/grape_oauth2/strategies/base.rb, line 27
def scopes_from(request)
  return nil if request.scope.nil?

  Array(request.scope).join(' ')
end