def _is_expired_response ( self , response ) : if response . status_code != 401 : return False challenge = response . headers . get ( 'www-authenticate' , '' ) return 'error="invalid_token"' in challenge
check if authentication failed with requests in python
Check if the response failed because of an expired access token .
def _is_expired_response(self, response):
        """
        Check if the response failed because of an expired access token.
        """
        if response.status_code != 401:
            return False
        challenge = response.headers.get('www-authenticate', '')
        return 'error="invalid_token"' in challenge