One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
Cato2021
3 years agoExplorer | Level 4
Still getting error even when using Dropbox-API-Select-Admin header with as_admin method
Hi,
Greg-DB, last time you helped me, maybe also this time?
I'm trying to traverse a team's files and folder while having a Dropbox Business team access token.
This is my code:
dbx_t = DropboxTeam(token)
dbx_t_as_admin = dbx_t.as_admin(<team_member_id str>)
namespaces_list_obj = dbx_t.team_namespaces_list()
for namespace_meta in namespaces_list_obj.namespaces:
ns = namespace_meta.namespace_id
files_meta = dbx_t_as_admin.files_list_folder(path='ns:'+ns)
The code fell on the last line.
Getting this error:
'Error in call to API function "files/list_folder": This API function operates on a single Dropbox account, but the OAuth 2 access token you provided is for an entire Dropbox Business team. Since your API app key has team member file access permissions, you can operate on a team member\'s Dropbox by providing the "Dropbox-API-Select-User" HTTP header or "select_user" URL parameter to specify the exact user.
I thought the as_admin method suppose to handle the "Dropbox-API-Select-Admin" header...
What am I doing wrong?
Thank you.
- Cato2021Explorer | Level 4
BTW I also tried the as_user method...
- Greg-DB
Dropbox Staff
This error message is referring to specifying what account on the Business team to operate on behalf of. For reference, when using any "team scopes", the resulting access token is connected to an entire Dropbox Business team, not an individual account. So, when using a team-scoped access token to access user-specific endpoints, such as files_list_folder, you will need to specify which member of the team you want to operate on behalf of. (By the way, make sure you implement files_list_folder_continue as well as files_list_folder, as described in the files_list_folder documentation, otherwise you may not get back all entries.)
To do this, you'd need to specify the 'Dropbox-API-Select-User' or 'Dropbox-API-Select-Admin' header as needed/desired. In the Python SDK, you should use the DropboxTeam.as_user or DropboxTeam.as_admin method, respectively, to get a client with that set. The value should be the team_member_id for whichever member you wish to act on behalf of. For example, you can find team member IDs by calling team_members_get_info_v2 or team_members_list_v2/team_members_list_continue_v2.I see you already showed using "as_admin" in your code, and also mentioned using "as_user" though. I tried the code you shared, plugging in my own access token and team member ID values, and it did work successfully for me. Can you double check that this is the exact code you're running when you see this error, and that you're successfully passing in a team_member_id value?
- Cato2021Explorer | Level 4
Correct, <team_member_id> was accidentally a None obj ...
Thank you...
About Discuss Dropbox Developer & API
Make connections with other developers804 PostsLatest Activity: 2 days ago
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!