I had some experience with boxsdk Python. Now, need to develop some automation script for a new project. Seems like box-sdk-gen is the recommended option. Below is a simple script to show my question. The script below works till the line to access a folder. I tried both client and user_client, both got error to access a specific folder. I can only access folder '0' with client. The App Access Level is "App + Enterprise Access". With the same app config, I can access all folders and files using boxsdk. It just doesn't work with new box-sdk-gen (Python). Please suggest what I am missing here. Thanks.
from box_sdk_gen import BoxClient, BoxJWTAuth, JWTConfig
jwt_config = JWTConfig.from_config_file(config_file_path="/path_to_config/config.json")
auth = BoxJWTAuth(config=jwt_config)
client = BoxClient(auth=auth)
service_account = client.users.get_user_me()
print(f"Service Account user ID is {service_account.id}")
user_auth = auth.with_user_subject("my_user_id")
user_client = BoxClient(auth=user_auth)
# auth.retrieve_token()
# print(f"Impersonating user: {user_client.users.get_user_me().name} (ID: {user_client.users.get_user_me().id})")
user = client.users.get_user_by_id('my_user_id')
print(f"Impersonating user: {user.name} (ID: {user.id})")
folder = client.folders.get_folder_by_id('folder_id')
print(f"Folder name is {folder.name}")
Service Account user ID is xxxx
Impersonating user: my_user_name (ID: xxxx)
Traceback (most recent call last):
File ".../test2.py", line 19, in <module>
folder = client.folders.get_folder_by_id('folder_id')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/.../.pyenv/versions/box_int_env/lib/python3.11/site-packages/box_sdk_gen/managers/folders.py", line 425, in get_folder_by_id
response: FetchResponse = self.network_session.network_client.fetch(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/.../.pyenv/versions/box_int_env/lib/python3.11/site-packages/box_sdk_gen/networking/box_network_client.py", line 141, in fetch
self._raise_on_unsuccessful_request(
File "/Users/.../.pyenv/versions/box_int_env/lib/python3.11/site-packages/box_sdk_gen/networking/box_network_client.py", line 261, in _raise_on_unsuccessful_request
raise BoxAPIError(
box_sdk_gen.box.errors.BoxAPIError:
Timestamp: 2025-09-11 10:08:38.871339
Underlying error: None
Message: 404 Not Found; Request ID: ry0gfui5a3w3qwnj
Request:
Method: GET
URL: https://api.box.com/2.0/folders/folder_id
Query params:
{}
Headers:
{ 'Authorization': '---[redacted]---',
'Content-Type': 'application/json',
'User-Agent': 'box-python-generated-sdk-1.17.0',
'X-Box-UA': 'agent=box-python-generated-sdk/1.17.0; env=python/3.11.13'}
Body: None
Response:
Status code: 404
Headers:
{ 'Alt-Svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000',
'Transfer-Encoding': 'chunked',
'box-request-id': '02484a93df31aef7756b661e0b1930900',
'cache-control': 'no-cache, no-store',
'content-type': 'application/json',
'date': 'Thu, 11 Sep 2025 14:08:38 GMT',
'strict-transport-security': 'max-age=31536000',
'via': '1.1 google',
'x-envoy-upstream-service-time': '141'}
Code: not_found
Context Info:
{ 'errors': [ { 'message': "Invalid value 'd_folder_id'. "
"'item' with value "
"'d_folder_id' not found",
'name': 'item',
'reason': 'invalid_parameter'}]}
Request Id: ry0gfui5a3w3qwnj
Help Url: http://developers.box.com/docs/#errors
Body:
{ 'code': 'not_found',
'context_info': { 'errors': [ { 'message': 'Invalid '
'value '
"'d_folder_id'. "
"'item' "
'with '
'value '
"'d_folder_id' "
'not '
'found',
'name': 'item',
'reason': 'invalid_parameter'}]},
'help_url': 'http://developers.box.com/docs/#errors',
'message': 'Not Found',
'request_id': 'ry0gfui5a3w3qwnj',
'status': 404,
'type': 'error'}
Description of the Issue
I had some experience with boxsdk Python. Now, need to develop some automation script for a new project. Seems like box-sdk-gen is the recommended option. Below is a simple script to show my question. The script below works till the line to access a folder. I tried both client and user_client, both got error to access a specific folder. I can only access folder '0' with client. The App Access Level is "App + Enterprise Access". With the same app config, I can access all folders and files using boxsdk. It just doesn't work with new box-sdk-gen (Python). Please suggest what I am missing here. Thanks.
Steps to Reproduce
Error Message, Including Stack Trace
Versions Used
Python SDK: <1.17.0>
Python: <3.11.13>