Great, thanks for the insight.
Seems perfectly doable.
Let’s start by how to “collaborate” external users, here is a sample script for you:
from boxsdk import OAuth2, Client
from boxsdk.object.collaboration import CollaborationRole
DEV_TOKEN = "ILH...KW"
FOLDER_ID = "213534631621"
def main():
auth = OAuth2(
client_id="",
client_secret="",
access_token=DEV_TOKEN,
)
client = Client(auth)
me = client.user().get()
print(f"I am {me.name} ({me.login})")
folder = client.folder(folder_id=FOLDER_ID).get()
print(f"Folder name: {folder.name} ({folder.id})")
collab = folder.collaborate_with_login(
"barbasr+222@gmail.com", CollaborationRole.EDITOR
)
print(
f"Collaboration ID: {collab.id} status: {collab.status} role: {collab.role} invite: {collab.invite_email}"
)
collaborators = folder.get_collaborations()
print(f"Folder {folder.name} ({folder.id}) collaborators:")
for collaborator in collaborators:
print(
f"\tCollaborator: {collaborator.id} {collaborator.status} role: {collaborator.role} invite: {collaborator.invite_email})"
)
collab.delete()
if __name__ == "__main__":
main()
The output looks like this (on my machine 🙂):
I am Rui Barbosa (barduinor@gmail.com)
Folder name: 4PL8AF (213534631621)
Collaboration ID: 45548719393 status: pending role: editor invite: barbasr+222@gmail.com
Folder 4PL8AF (213534631621) collaborators:
Collaborator: 45548719393 pending role: editor invite: barbasr+222@gmail.com)
Collaborator: 45550301448 accepted role: editor invite: None)
Collaboration 45548719393 deleted
In essence the collaborations end point accepts an internal user, an external user or a group id, so you can do for an internal user:
user = client.user(user_id='11111')
collaboration = client.folder(folder_id='22222').collaborate(user, CollaborationRole.VIEWER)
or for a group:
group = client.group(group_id='11111')
collaboration = client.folder(folder_id='22222').collaborate(group, CollaborationRole.VIEWER)
or for any user (including external users)
email_of_invitee = 'testuser@example.com'
collaboration = client.folder(folder_id='22222').collaborate_with_login(email_of_invitee, CollaborationRole.VIEWER)
Let us know if this helps
Cheers