Revoking Access from a User
Problem
You need to revoke a user’s access to a content item.
Solution
from posit import connect
= "c92da1ad-9c48-420f-8e2a-dcd2d58f9723"
CONTENT_GUID = "20a79ce3-6e87-4522-9faf-be24228800a4"
USER_GUID
= connect.Client()
client
# Remove a single permission using a GUID
client.content.get(CONTENT_GUID).permissions.destroy(USER_GUID)
# Remove a single permission using a User object
= client.users.get(principal_guid)
user
client.content.get(CONTENT_GUID).permissions.destroy(user)
# Confirm new permissions
client.content.get(CONTENT_GUID).permissions.find()
library(connectapi)
<- "c92da1ad-9c48-420f-8e2a-dcd2d58f9723"
CONTENT_GUID <- "20a79ce3-6e87-4522-9faf-be24228800a4"
USER_GUID
<- connect()
client
# For the specified content item remove the desired user
<- content_item(client, CONTENT_GUID)
content content_delete_user(content, USER_GUID)
# Confirm new permissions
get_content_permissions(content)