We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

AdanHerrera's avatar
AdanHerrera
Explorer | Level 3
7 years ago
Solved

Dropbox API Python

Hello,

 

Please I need help, How can I do this with Business API

 

import dropbox

client = dropbox.Dropbox('JCJoqsBi2DAAAAGGHFHFGH')


for entry in client.files_list_folder('').entries:
print(entry)

  • If you have a Dropbox Business API app with the "team member file access" permission, and want to use a user-specific API call, such as files_list_folder, you can do so using DropboxTeam.as_user.

     

    First, you should make your DropboxTeam instance, and then use DropboxTeam.as_user to get a Dropbox instance. You can then use that Dropbox instance normally for user API calls. That would look like this:

     

     

    import dropbox
    
    TEAM_MEMBER_FILE_ACCESS_ACCESS_TOKEN = '...'
    TEAM_MEMBER_ID = 'dbmid:...'
    
    team_client = dropbox.DropboxTeam(TEAM_MEMBER_FILE_ACCESS_ACCESS_TOKEN)
    user_client = team_client.as_user(TEAM_MEMBER_ID)
    
    for entry in user_client.files_list_folder('').entries:
        print(entry)
    

    You can get the member ID for the desired member from the Dropbox Business API, in a TeamMemberInfo, e.g., as returned by team_members_list/team_members_list_continue or team_members_get_info, etc.

     

  • Greg-DB's avatar
    Greg-DB
    7 years ago

    That would look like this, for example:

    team_member_info = team_client.team_members_get_info([dropbox.team.UserSelectorArg.email(member_email_address)]).pop()
    if team_member_info and team_member_info.is_member_info():
        team_member_id = team_member_info.get_member_info().profile.team_member_id

3 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    7 years ago

    If you have a Dropbox Business API app with the "team member file access" permission, and want to use a user-specific API call, such as files_list_folder, you can do so using DropboxTeam.as_user.

     

    First, you should make your DropboxTeam instance, and then use DropboxTeam.as_user to get a Dropbox instance. You can then use that Dropbox instance normally for user API calls. That would look like this:

     

     

    import dropbox
    
    TEAM_MEMBER_FILE_ACCESS_ACCESS_TOKEN = '...'
    TEAM_MEMBER_ID = 'dbmid:...'
    
    team_client = dropbox.DropboxTeam(TEAM_MEMBER_FILE_ACCESS_ACCESS_TOKEN)
    user_client = team_client.as_user(TEAM_MEMBER_ID)
    
    for entry in user_client.files_list_folder('').entries:
        print(entry)
    

    You can get the member ID for the desired member from the Dropbox Business API, in a TeamMemberInfo, e.g., as returned by team_members_list/team_members_list_continue or team_members_get_info, etc.

     

  • AdanHerrera's avatar
    AdanHerrera
    Explorer | Level 3
    7 years ago
    Can you show me show to do this: "You can get the member ID for the desired member from the Dropbox Business API, in a TeamMemberInfo, e.g., as returned by team_members_list/team_members_list_continue or team_members_get_info, etc."

    I'm a rookie and I'm a little lost... thanks
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    7 years ago

    That would look like this, for example:

    team_member_info = team_client.team_members_get_info([dropbox.team.UserSelectorArg.email(member_email_address)]).pop()
    if team_member_info and team_member_info.is_member_info():
        team_member_id = team_member_info.get_member_info().profile.team_member_id

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API
Make connections with other developers815 PostsLatest Activity: 6 hours ago
276 Following

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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!