Skip to main content

Hello, this is Yane



I created a folder using the BOX API.


However, I can’t find the folder created in all files on the browser.



You can find the created folder by searching the folder with BOX API.


Why can’t I see the folder I created in all files on my browser?



code:


from boxsdk import Client


from boxsdk import CCGAuth



# Arguments fetched from the BOX management screen



CLIENT_ID = ‘aaaaaaaaaaaaaa’


CLIENT_SECRET = ‘dddddddddd’ # client secret code’


ENTERPRISE_ID = ‘cccccccccccccc’



auth = CCGAuth(


client_id=CLIENT_ID,


client_secret=CLIENT_SECRET,


enterprise_id=ENTERPRISE_ID


)



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"



Process completed with exit code 0

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.


Hello, this is Yane



Thank you for contacting us.


I was able to understand the meaning.


thank you very much. It was helpful.


How to see the folders using service account?


Hi @user67 ! 🙂


You can use the Folders endpoint : https://developer.box.com/reference/get-folders-id-items/



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 :



https://*.app.box.com/folder/0


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.



Let us know if this worked for you.


Reply