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
CONTENT_GUID = "a080baef-854e-411f-ac3c-d2bc47bcb109"
INTEGRATION_GUID = "84f0f0ae-e328-44b0-98ba-aee6e775b5f0"
client = connect.Client()
content = client.content.get(CONTENT_GUID)
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)
CONTENT_GUID <- "a080baef-854e-411f-ac3c-d2bc47bcb109"
INTEGRATION_GUID <- "84f0f0ae-e328-44b0-98ba-aee6e775b5f0"
json_payload <- toJSON(list(
list(
oauth_integration_guid = INTEGRATION_GUID,
)
), auto_unbox = TRUE)
client <- connect()
client$PUT(paste0("v1/content/", CONTENT_GUID, "/oauth/integrations/associations"), body = json_payload)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.