module Doorkeeper::Request

def token_strategy(grant_type)

def token_strategy(grant_type)
  raise Errors::MissingRequiredParameter, :grant_type if grant_type.blank?
  grant_flow = token_flows.detect do |flow|
    flow.matches_grant_type?(grant_type)
  end
  if grant_flow
    grant_flow.grant_type_strategy
  else
    # [NOTE]: this will be removed in a newer versions of Doorkeeper.
    # For retro-compatibility only
    raise Errors::InvalidTokenStrategy unless available.include?(grant_type.to_s)
    strategy_class = build_fallback_strategy_class(grant_type)
    raise Errors::InvalidTokenStrategy unless strategy_class
    strategy_class
  end
end