'builds the authentication error'

def build_authentication(self, stale=''):

    content = ('%s:%s' % (time.time(), random.random()))
    if six.PY3:
        content = content.encode('utf-8')
    nonce = md5(content).hexdigest()
    content = ('%s:%s' % (time.time(), random.random()))
    if six.PY3:
        content = content.encode('utf-8')
    opaque = md5(content).hexdigest()
    self.nonce[nonce] = None
    parts = {'realm': self.realm, 'qop': 'auth', 'nonce': nonce, 'opaque': opaque}
    if stale:
        parts['stale'] = 'true'
    head = ',    '.join([('%s="%s"' % (k, v)) for (k, v) in parts.items()])
    head = [('WWW-Authenticate', ('Digest    %s' % head))]
    return HTTPUnauthorized(headers=head)
