def get_api_key(required_role: Roles::PUBLIC)
        api_key = params[:api_key]
        if api_key.nil?
          # This case is not likely, but as a safeguard in case migration
          # has not gone well.
          # :nocov:
          raise UNAUTHORIZED_ERROR, "Invalid api key"
          # :nocov:
        end
        auth_user = User.find_by_api_key(api_key)
        if auth_user.nil? || auth_user.role < required_role
          raise UNAUTHORIZED_ERROR, "Invalid api key"
        end
        @auth_user = auth_user
        @auth_session = nil
        @token = nil
        return true
      end
def get_api_key(required_role: Roles::PUBLIC)
        api_key = params[:api_key]
        if api_key.nil?
          # This case is not likely, but as a safeguard in case migration
          # has not gone well.
          # :nocov:
          raise UNAUTHORIZED_ERROR, "Invalid api key"
          # :nocov:
        end
        auth_user = User.find_by_api_key(api_key)
        if auth_user.nil? || auth_user.role < required_role
          raise UNAUTHORIZED_ERROR, "Invalid api key"
        end
        @auth_user = auth_user
        @auth_session = nil
        @token = nil
        return true
      end
Get API key from the request.

 Raises a UNAUTHORIZED_ERROR if API key is not valid (or not
 provided).