Revoking Access from a User

Problem

You need to revoke a user’s access to a content item.

Solution

from posit import connect

CONTENT_GUID = "c92da1ad-9c48-420f-8e2a-dcd2d58f9723"
USER_GUID = "20a79ce3-6e87-4522-9faf-be24228800a4"

client = connect.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
user = client.users.get(principal_guid)
client.content.get(CONTENT_GUID).permissions.destroy(user)

# Confirm new permissions
client.content.get(CONTENT_GUID).permissions.find()
library(connectapi)

CONTENT_GUID <- "c92da1ad-9c48-420f-8e2a-dcd2d58f9723"
USER_GUID <- "20a79ce3-6e87-4522-9faf-be24228800a4"

client <- connect()

# For the specified content item remove the desired user
content <- content_item(client, CONTENT_GUID)
content_delete_user(content, USER_GUID)

# Confirm new permissions
get_content_permissions(content)