'Takes the response authenticates and resends if neccissary
:return: The final response to the authenticated request
:rtype: requests.Response'

def handle_401(self, response, **kwargs):

    if (not (response.status_code == 401)):
        self._thread_local.auth_attempted = False
        return response
    auth_header = response.headers.get('www-authenticate', '')
    if (not HttpBearerChallenge.is_bearer_challenge(auth_header)):
        self._thread_local.auth_attempted = False
        return response
    if self._thread_local.auth_attempted:
        self._thread_local.auth_attempted = False
        return response
    self._thread_local.auth_attempted = True
    if (self._thread_local.pos is not None):
        response.request.body.seek(self._thread_local.pos)
    challenge = HttpBearerChallenge(response.request.url, auth_header)
    ChallengeCache.set_challenge_for_url(response.request.url, challenge)
    response.content
    response.close()
    prep = response.request.copy()
    extract_cookies_to_jar(prep._cookies, response.request, response.raw)
    prep.prepare_cookies(prep._cookies)
    self.set_authorization_header(prep, challenge)
    _response = response.connection.send(prep, **kwargs)
    _response.history.append(response)
    _response.request = prep
    return _response
