We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.

Forum Discussion

JessicaPaul's avatar
JessicaPaul
New member | Level 2
4 years ago

Query Dropbox API

Hello.
I am trying to query Dropbox using python's from dropbox import DropboxTeam request_json_object API.
I need to  query the API path: files/list_folder
My request look like

 

 

 

 

request_json_object(dict(
    host='api',
    auth_type='team',
    route_style='rpc',
    request_binary=None,
    route_name='files/list_folder',
    request_arg={'limit': 1, 'select_user': 'userid:111...111'}
))

 

 

 

 



But I am getting this error BadInputError

'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
https://www.dropbox.com/developers/documentation/http/teams 



  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    First, note that you don't need to use the request_json_object method directly. You should use the provided native methods for the API endpoints, such as files_list_folder for /2/files/list_folder.

     

    Anyway, this error message is referring to specifying what account on the Business team to operate on behalf of. 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 /2/files/list_folder via the files_list_folder method in the Python SDK, you will need to specify which member of the team you want to operate on behalf of. 

    To do this, you'd need to specify the 'Dropbox-API-Select-User' header. The value should be the team_member_id for whichever member you wish to act on behalf of. In the Python SDK, that can be done using the DropboxTeam.as_user method.


    Alternatively, if you just want to connect to your particular account, you can disable any team scopes and get a new access token without them. The access token without the team scopes will be specific to the particular account (Business or not) and so will not require the additional header. You can find more information on scopes in the OAuth Guide. If you don't need to call any team endpoints (e.g., if you just need to call file endpoints, such as /2/files/list_folder via the files_list_folder method), you may prefer to use this solution instead for simplicity and security.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,875 PostsLatest Activity: 2 months ago
325 Following

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!