Extend collaborations using Python SDK
回答済みHi,
I'm trying to extend collaborations on certain folders using Box Python SDK. I have been searching this forum for possible solutions but haven't found any. The thread below is the closest related issue found, but it addresses another issue. It is marked as 'Solved', therefore I'm posting this new message.
Extend Access to External collaborators using Box API.
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 code that 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!
-
Hi , let's see if I can help with this.
I'm not too sure why . you are fetching collaborations when you want to add a new one. A collaboration is essentially a mapping between 1 item (folder, file, etc) and 1 user or group.
In this case, if you want to add a new collaboration for an external user, you simply want to use the `POST /collaborations/` endpoint. https://box.dev/en/reference/post-collaborations/
I this case, you will want to invite the user by email as follows:
from boxsdk.object.collaboration import CollaborationRole email_of_invitee = 'testuser@example.com' collaboration = client.folder(folder_id='22222').collaborate_with_login(email_of_invitee, CollaborationRole.VIEWER)
-
Hi , I'm not sure this is what I want to do.
As a clarification; the correct users are already collaborated on the correct folders. However, the access to folders of certain users expires after 60 days, so (I think) the collaboration expires after this time. It seems like I want to extend these collaborations instead of adding them as new users.
-
Ah yes, that is a different use case. In that case, I'd first recommend looking into your enterprise settings and confirm if this feature has been configured to allow extending. If it has, I think you can updated the `expires_at` field of the collaboration using this endpoint:
https://box.dev/en/reference/put-collaborations-id/
If it is not set, you will need to delete and then reinvite the user.
-
Thanks again for your reply. Extending is collaborations is allowed according to the enterprise settings.
Unfortunately, updating the 'expires_at' field did not work using update_collaboration. Indeed, another option (the final option imo) would be removing and adding collaborations to refresh the expiration date. However, this would not be preferable in our enterprise.
If this feature would be added in the future I would love to know!
Thanks again for the suggestions! I'll mark this post as solved for now.
-
I am having the same problem, I can use the Try this API to update the expiration to a distant date, but full removal of the expiration would be a helpful feature.
投稿コメントは受け付けていません。
コメント
5件のコメント