code: 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
docs: Check if the response failed because of an expired access token.