diff --git a/docs/changelog.rst b/docs/changelog.rst index 168517f..e535dfb 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,10 @@ Changelog --------- +4.1.1 +~~~~~ +* Refresh tokens on 429 response codes + 4.1.0 ~~~~~ * Add `revision_control` as an allowed upload parameter. diff --git a/documentcloud/client.py b/documentcloud/client.py index 6333adb..a8f98f5 100644 --- a/documentcloud/client.py +++ b/documentcloud/client.py @@ -143,7 +143,10 @@ def _request(self, method, url, raise_error=True, **kwargs): method, url, timeout=self.timeout, **kwargs ) logger.debug("response: %s - %s", response.status_code, response.content) - if response.status_code == requests.codes.FORBIDDEN and set_tokens: + if ( + response.status_code in [requests.codes.FORBIDDEN, requests.codes.TOO_MANY] + and set_tokens + ): self._set_tokens() # track set_tokens to not enter an infinite loop kwargs["set_tokens"] = False diff --git a/setup.py b/setup.py index 2e7d3bf..fb0ec43 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name="python-documentcloud", - version="4.1.0", + version="4.1.1", description="A simple Python wrapper for the DocumentCloud API", author="Mitchell Kotler", author_email="mitch@muckrock.com",