client = Client(auth)
print(f’Id of the authenticated user is: {client.user().get().id}‘)
subfolder = client.folder(‘0’).create_subfolder(‘My Stuff’)
print(f’Created subfolder with ID {subfolder.id}’)
list items in folder
items = client.folder(folder_id=‘0’).get_items()
for items in items:
print(f’{item.type.capitalize()} , {item.name}"')
result:
Id of the authenticated user is: 27822023285
All Files
Folder , My Stuff"
Hi @nobuhiro_yane !
The user ID you mentioned is not a physical user, it’s a service account.
So the folder does exist indeed, but under the Service account folder tree !
That’s why you don’t see it if you’re logged in with your usual user account.
If you select the Folder ID 0, then it will return all the items (files, folders, web links) located on the root of the Service Account. You should use this endpoint :
My issue is when i create a folder or upload a file using default bearer token i am able to see the folder in root directory. when i create a folder or upload a file using generated bearer token i couldnt see the files folders in root 0 dir
I am generating token from comand below
curl -X POST “https://api.box.com/oauth2/token”
-H “Content-Type: application/x-www-form-urlencoded”
-d “grant_type=client_credentials”
-d “client_id=ID”
-d “client_secret=SECRET”
i am using a sandbox account
Hi,
When you use a client credentials grant type (CCG) it is important that you include the box_subject_type and the box_subject_id.
I’m not sure what you mean by default bearer token vs generated bearer token.
Do you mean developer token vs CCG token?
What I suspect is happening here is that your are using 2 different bearer tokens that belong to 2 different users.
Event with full permissions the CCG or JWT tokens associated with users or service user accounts, can only access the content that they own or has been shared with then, unless the service accounts are impersonating a use with the as-user header.
So most likely in your use case, you’re creating a folder or uploading a file with a user and then trying to access it with another user.
If indeed you’re using a developer token, please take into consideration that the token is associated with the user account of the user who created it and not the service account.
You can easily check who’s account you’re working with by calling the /users/me endpoint or the associated method on all SDK’s.