code: def raise_401(instance, authenticate, msg=None):
      
      instance.response.status = 401
      instance.response.headers['WWW-Authenticate'] = authenticate
      if msg:
          instance.response.body_raw = {'error': msg}
      raise ResponseException(instance.response)
docs: Abort the current request with a 401 (Unauthorized) response code. If
      the message is given it's output as an error message in the response body
      (correctly converted to the requested MIME type). Outputs the
      WWW-Authenticate header as given by the authenticate parameter.
  
      :param instance: Resource instance (used to access the response)
      :type instance: :class:`webob.resource.Resource`
      :raises: :class:`webob.exceptions.ResponseException` of status 401