Associate Integrations with Content
Problem
You want to associate an integration with a content item.
Solution
Get a content item and an integration, then use the content item’s oauth.associations.update()
method to associate them.
from posit import connect
= "a080baef-854e-411f-ac3c-d2bc47bcb109"
CONTENT_GUID = "84f0f0ae-e328-44b0-98ba-aee6e775b5f0"
INTEGRATION_GUID
= connect.Client()
client = client.content.get(CONTENT_GUID)
content content.oauth.associations.update(INTEGRATION_GUID)
Get the content item’s guid and integration guid, then use the connectapi
client to make a direct call to the associations endpoint.
library(jsonlite)
library(connectapi)
<- "a080baef-854e-411f-ac3c-d2bc47bcb109"
CONTENT_GUID <- "84f0f0ae-e328-44b0-98ba-aee6e775b5f0"
INTEGRATION_GUID
<- toJSON(list(
json_payload list(
oauth_integration_guid = INTEGRATION_GUID,
)auto_unbox = TRUE)
),
<- connect()
client
$PUT(paste0("v1/content/", CONTENT_GUID, "/oauth/integrations/associations"), body = json_payload) client
Discussion
To view the newly created association follow the Finding Integrations Associated to Content recipe.
See also
- For more details about the data returned in this recipe, see List all OAuth integration associations for this content item in the API Reference.
- See OAuth Integrations in the User Guide to learn more about how publishers and viewers interact with OAuth integrations.
- See OAuth Integrations in the Admin Guide to for more detailed information on how to configure OAuth integrations.