cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Discuss Dropbox Developer & API

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

Dropbox API Python

Dropbox API Python

AdanHerrera
Explorer | Level 3
Go to solution

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)

2 Accepted Solutions

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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.

 

View solution in original post

Greg-DB
Dropbox Staff
Go to solution

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

View solution in original post

3 Replies 3

Greg-DB
Dropbox Staff
Go to solution

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
Explorer | Level 3
Go to solution
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
Dropbox Staff
Go to solution

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
Need more support?
Who's talking

Top contributors to this post

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