Skip to content

Instantly share code, notes, and snippets.

@drewgillson
Created May 31, 2023 03:08
Show Gist options
  • Save drewgillson/fe9a7f582d507021e33f03b80a4d6f53 to your computer and use it in GitHub Desktop.
Save drewgillson/fe9a7f582d507021e33f03b80a4d6f53 to your computer and use it in GitHub Desktop.
#!/bin/bash
TOKEN=$(gcloud auth application-default print-access-token)
PROJECT_ID="663188713804"
DOCUMENT_ID="29oiqkhlqm5o8"
ENDPOINT="https://contentwarehouse.googleapis.com/v1/projects/$PROJECT_ID/locations/us/documents/$DOCUMENT_ID:setAcl"
# Set the policy
POLICY='{
"policy": {
"bindings": [
{
"role": "roles/contentwarehouse.documentViewer",
"members": [
"user:[email protected]"
]
}
]
},
"requestMetadata": {
"userInfo": {
"id": "user:[email protected]",
"groupIds": []
}
}
}'
# Make an API request to grant [email protected] contentwarehouse.documentViewer privileges
echo $ENDPOINT
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "$POLICY" \
$ENDPOINT | jq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment