You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

Aryahagh's avatar
Aryahagh
New member | Level 2
5 years ago

Reading programmatically several files from Dropbox business

Hi I want to read (or only reading is not possible, download) several files in different folders ,which is stored in a Dropbox buisiness account, programmatically in python. I were able to create a...
  • Greg-DB's avatar
    5 years ago

    If you only want to access the files in one particular account, you can register a "Dropbox API" app with the "Full Dropbox" permission and then use the /2/files/download endpoint to download files from a connected account without any extra configuration. (You can also connect the app to multiple different accounts, but each user would need to authorize their own account, to give the app a distinct access token for each one.) That would look like this:

     

    curl -X POST https://content.dropboxapi.com/2/files/download \
        --header "Authorization: Bearer <ACCESS_TOKEN>" \
        --header "Dropbox-API-Arg: {\"path\": \"/test.txt\"}"

     

    Or, using the Python SDK:

     

    dbx = dropbox.Dropbox(ACCESS_TOKEN)
    
    print(dbx.files_download("/test.txt"))

     

    If you want to be able to access the files any team member's account on a Business team, by only having a team admin authorize the app once, you will need to register a "Dropbox Business API" app with the "team member file access" permission and then use the /2/files/download endpoint to download files, but with some extra configuration as covered in the "Member file access" section of the Business API documentation. Since Dropbox Business API apps are connected to the entire Business team, you need to specify which member you want to operate on when making a user-level call, such as /2/files/download. You can do so by specifying the Dropbox-API-Select-User" header with the value being the team member ID of the member you want to call for. The team member ID starts with "dbmid:" and can be retrieved from the Dropbox Business API, such as via /2/team/members/get_info or /2/team/members/list[/continue]. That would look like this:

     

    curl -X POST https://content.dropboxapi.com/2/files/download \
        --header "Authorization: Bearer <TEAM_ACCESS_TOKEN>" \
        --header "Dropbox-API-Select-Admin: <TEAM_MEMBER_ID>" \
        --header "Dropbox-API-Arg: {\"path\": \"/test.txt\"}"

     

    Or, using the Python SDK:

     

    dbx = dropbox.DropboxTeam(TEAM_ACCESS_TOKEN).as_user(TEAM_MEMBER_ID)
    
    print(dbx.files_download("/test.txt"))

     

     

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,883 PostsLatest Activity: 22 hours ago
326 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!