def before
      set_auth_strategy(GrapeSimpleAuth.auth_strategy)
      auth_strategy.api_context = context
      context.extend(GrapeSimpleAuth::AuthMethods)

      context.protected_endpoint = endpoint_protected?
      context.optional_endpoint = optional_endpoint?

      return unless context.protected_endpoint? || context.optional_endpoint?
      
      self.the_request = env
      
      if token.present? && (context.protected_endpoint? || context.optional_endpoint?)
        resp = authorize!(*auth_scopes)
        context.the_access_token = token
        context.current_user = resp.parsed_response["data"]["info"] rescue nil
        context.credentials = resp.parsed_response["data"]["credential"] rescue nil
      elsif token.nil? && context.protected_endpoint?
        raise GrapeSimpleAuth::Errors::InvalidToken
      end
    end
def before
      set_auth_strategy(GrapeSimpleAuth.auth_strategy)
      auth_strategy.api_context = context
      context.extend(GrapeSimpleAuth::AuthMethods)

      context.protected_endpoint = endpoint_protected?
      context.optional_endpoint = optional_endpoint?

      return unless context.protected_endpoint? || context.optional_endpoint?
      
      self.the_request = env
      
      if token.present? && (context.protected_endpoint? || context.optional_endpoint?)
        resp = authorize!(*auth_scopes)
        context.the_access_token = token
        context.current_user = resp.parsed_response["data"]["info"] rescue nil
        context.credentials = resp.parsed_response["data"]["credential"] rescue nil
      elsif token.nil? && context.protected_endpoint?
        raise GrapeSimpleAuth::Errors::InvalidToken
      end
    end
Grape middleware methods