cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Still getting error even when using Dropbox-API-Select-Admin header with as_admin method

Still getting error even when using Dropbox-API-Select-Admin header with as_admin method

Cato2021
Explorer | Level 4

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.

3 Replies 3

Cato2021
Explorer | 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?

Cato2021
Explorer | Level 4

Correct, <team_member_id> was accidentally a None obj ...
Thank you...

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Cato2021 Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?