Restrict Shared Link Access for Folder Programmatically?
Happy Sunday everyone! I'm looking for a way to automatically restrict shared links on a folder to only collaborators via the Box API. For reference, here's the setting I'm talking about as presented through the UI:
Looking at the documentation, folders seem to have a property called `allowed_shared_link_access_levels`, but when I attempt to modify this via the `update_info` method in the Python SDK, it doesn't seem to make the change. Code excerpt below:
auth = boxsdk.JWTAuth.from_settings_file('authfile') client = boxsdk.Client(auth) folder = client.folder(folder_id='68281051900').get() update = folder.update_info({ 'allowed_shared_link_access_levels': ['collaborators'] })
Can anyone provide insight as to what I'm doing wrong here? Is this not the correct property to attempt to update? Thanks much in advance! 😄
-
Hey ,
The screenshot you took is off folder level settings. Folder level settings is not exposed via API so the field you are trying to set is read-only.
Alternatively, you can set the shared links to collaborators only by altering the shared link itself. This will not trickle across the shared links in the folder. You will have to loop through the files and folders and retrieve the shared link and update the permission from there.
The call to update a shared link is as follows:
folder = client.folder('50167809963').get().get_shared_link(access='collaborators')
Let us know if you run into any issues, thanks!
-
Thanks for the reply! Unfortunately, what I'm hoping to accomplish here is to restrict any shared links made moving forward with the account to collaborators-only, so rolling through existing links and changing them doesn't help with this particular scenario. Looking in my own account settings, I see that there's a way to restrict shared link access at the user account level, though I'm not seeing a corresponding attribute for a user via the API. Am I missing something? Thanks again!
Please sign in to leave a comment.
Comments
2 comments