Extend Access to External collaborators using Box API.

回答済み
新規投稿

コメント

2件のコメント

  • nadaoneal

    YES, you can do this. The documentation for the Collaboration object is here. You can add external collaborators either by ID (if they already exist) or via email, e.g.:

     

    curl https://api.box.com/2.0/collaborations \
    -H "Authorization: Bearer YOUR_TOKEN_HERE" \
    -d '{"item": { "id": "YOUR_FOLDER_ID_HERE", "type": "folder"}, "accessible_by": { "login": "SOME_EMAIL", "type": "user" }, "role": "ROLE_OF_YOUR_CHOICE"}' \
    -X POST

    ALSO, I recently learned that the collaboration object is fully supported in the Python SDK, though it's not documented. You just have to search the github repo to see that Collaboration object support is defined here, and the add_collaborator function is defined in folder.py

     

    A usage example is in example.py

     

        root_folder = client.folder(folder_id='0')
        collab_folder = root_folder.create_subfolder('collab folder')
        try:
            print('Folder {0} created'.format(collab_folder.get()['name']))
            collaboration = collab_folder.add_collaborator('SOME_EMAIL', CollaborationRole.VIEWER)
            print('Created a collaboration')

     

    0
    コメントアクション パーマリンク
  • KoenThijssen

    Hi,

     

    Isn't this how you add collaborators, whereas the question was how to extend collaborations?

     

    I am wondering how to extend the collaboration with external users using Python SDK. Creating folders and adding collaborators works but now I want to extend the collaborations. Is there a way to do this using Python SDK? 

     

    Below the what I tried using. 

     

    collaborations = client.folder(folder_id=folder_id).get_collaborations()
    for collab in collaborations:
    collab_role = collab.role
    collab_id = collab.id
    if collab_role == 'editor':
    role = CollaborationRole.EDITOR
    else:
    role = None
    collaboration = client.collaboration(collab_id=str(collab_id))
    updated_collaboration = collaboration.update_info(role)


    I would prefer to not remove collaborations and adding them again if that's possible.

    Suggestion are very welcome!

    0
    コメントアクション パーマリンク

サインインしてコメントを残してください。