Granting Access to a Group
Problem
You need to grant a group access to a content item.
Solution
from posit import connect
= "c92da1ad-9c48-420f-8e2a-dcd2d58f9723"
CONTENT_GUID = "286d77ab-cc4d-430d-848d-67c8179de942"
GROUP_GUID # Valid values are "viewer" and "owner" (collaborator)
= "viewer"
ACCESS_TYPE
= connect.Client()
client
# Add a group permission directly
= client.groups.get(GROUP_GUID)
group =ACCESS_TYPE)
client.content.get(CONTENT_GUID).permissions.create(group, role
# Add a group permission manually
client.content.get(CONTENT_GUID).permissions.create(=GROUP_GUID,
principal_guid="group",
principal_type=ACCESS_TYPE,
role
)
# Confirm new permissions
client.content.get(CONTENT_GUID).permissions.find()
library(connectapi)
<- "c92da1ad-9c48-420f-8e2a-dcd2d58f9723"
CONTENT_GUID <- "286d77ab-cc4d-430d-848d-67c8179de942"
GROUP_GUID # Valid values are "viewer" and "owner" (collaborator)
<- "viewer"
ACCESS_TYPE
<- connect()
client
# For the specified content item add the desired group
<- content_item(client, CONTENT_GUID)
content content_add_group(content, GROUP_GUID, role = ACCESS_TYPE)
# Confirm new permissions
get_content_permissions(content)