403 access denied error when iterating over the query response
My scripts authenticates using oauth and then runs a search query targeting the file name in box folder. Then we iterate over the results to get the metadata of each file. This is when we are seeing a 403 access denied error. This is also not happening on each run. Keep in mind that the data in the box folder changes on each run and results expected are different
Here is the traceback error
My scripts authenticates using oauth and then runs a search query targeting the file name in box folder. Then we iterate over the results to get the metadata of each file. This is when we are seeing a 403 access denied error. This is also not happening on each run. Keep in mind that the data in the box folder changes on each run and results expected are different
Here is the traceback error
```
Traceback (most recent call last):
File "./jobs/zerto_usage_collection.py", line 64, in fetch_box_reports
for result in results:
File "/usr/local/lib/python3.7/site-packages/boxsdk/pagination/box_object_collection.py", line 92, in next
return next(self._all_items)
File "/usr/local/lib/python3.7/site-packages/boxsdk/pagination/box_object_collection.py", line 102, in _items_generator
response_object = self._load_next_page()
File "/usr/local/lib/python3.7/site-packages/boxsdk/pagination/box_object_collection.py", line 138, in _load_next_page
box_response = self._session.get(self._url, params=params)
File "/usr/local/lib/python3.7/site-packages/boxsdk/session/session.py", line 101, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python3.7/site-packages/boxsdk/session/session.py", line 157, in request
response = self._prepare_and_send_request(method, url, **kwargs)
File "/usr/local/lib/python3.7/site-packages/boxsdk/session/session.py", line 391, in _prepare_and_send_request
retry = self._get_retry_request_callable(network_response, attempt_number, request)
File "/usr/local/lib/python3.7/site-packages/boxsdk/session/session.py", line 577, in _get_retry_request_callable
self._renew_session(network_response.access_token_used)
File "/usr/local/lib/python3.7/site-packages/boxsdk/session/session.py", line 547, in _renew_session
new_access_token, _ = self._oauth.refresh(access_token_used)
File "/usr/local/lib/python3.7/site-packages/boxsdk/auth/oauth2.py", line 266, in refresh
access_token, refresh_token = self._refresh(access_token_to_refresh)
File "/usr/local/lib/python3.7/site-packages/boxsdk/auth/oauth2.py", line 218, in _refresh
return self.send_token_request(data, access_token)
File "/usr/local/lib/python3.7/site-packages/boxsdk/auth/oauth2.py", line 401, in send_token_request
token_response = self._execute_token_request(data, access_token, expect_refresh_token)
File "/usr/local/lib/python3.7/site-packages/boxsdk/auth/oauth2.py", line 347, in _execute_token_request
six.raise_from(self._oauth_exception(box_api_excpetion.network_response, url), box_api_excpetion)
File "", line 3, in raise_from
boxsdk.exception.BoxOAuthException:
Message: Access denied
Status: 403
URL: https://api.box.com/oauth2/token
Method: POST
Headers: {'Date': 'Sun, 29 Mar 2020 18:00:24 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'X-Powered-By': 'PHP/7.1.33', 'Strict-Transport-Security': 'max-age=31536000', 'Set-Cookie': 'box_visitor_id=5e80e2385d0f39.95867363; expires=Mon, 29-Mar-2021 18:00:24 GMT; Max-Age=31536000; path=/; domain=.box.com; secure, bv=OPS-43575; expires=Sun, 05-Apr-2020 18:00:24 GMT; Max-Age=604800; path=/; domain=.app.box.com; secure, cn=80; expires=Mon, 29-Mar-2021 18:00:24 GMT; Max-Age=31536000; path=/; domain=.app.box.com; secure, site_preference=desktop; path=/; domain=.box.com; secure', 'Cache-Control': 'no-store', 'Content-Encoding': 'gzip'}
```
`
Can you help?
Please sign in to leave a comment.
Comments
0 comments