diff --git a/box/client.py b/box/client.py index bf20aed..3dd22c4 100644 --- a/box/client.py +++ b/box/client.py @@ -617,7 +617,7 @@ def upload_file(self, filename, fileobj, parent=0, content_created_at=None, cont - content_modified_at: (optional) a timestamp (datetime or a properly formatted string) of the time the content was last modified """ - + try_refresh=True form = {"parent_id": self._get_id(parent)} if content_created_at: @@ -631,7 +631,9 @@ def upload_file(self, filename, fileobj, parent=0, content_created_at=None, cont form, headers=self.default_headers, files={filename: (filename, fileobj)}) - + if response.status_code == UNAUTHORIZED and try_refresh and self.credentials.refresh(): + try_refresh=False + return self.upload_file(filename, fileobj) self._check_for_errors(response) return response.json()['entries'][0]