Updating Integrations
Problem
You want to update an integration. A common use case for this recipe is to update an expired client secret.
Solution
Warning
You must have administrator privileges to update an integration.
Use the integration GUID or follow the Finding Integrations recipe to get an integration, then use its update()
method.
from posit import connect
= "84f0f0ae-e328-44b0-98ba-aee6e775b5f0"
GUID
= {
NEW_INFORMATION "description": "New Description",
"config": {
"client_secret": "new-client-secret"
}
}
= connect.Client()
client = client.oauth.integrations.get(GUID)
integration integration.update(NEW_INFORMATION)
Follow the Finding Sessions recipe to get the session’s GUID, then use the connectapi
client to make a direct call to the sessions endpoint.
library(jsonlite)
library(connectapi)
<- "84f0f0ae-e328-44b0-98ba-aee6e775b5f0"
GUID
<- connect()
client
<- toJSON(list(
json_payload description = "New Description",
config = list(
client_secret = "new-client-secret"
)auto_unbox = TRUE)
),
<- client$PATCH(paste0("v1/oauth/integrations/", GUID), body = json_payload) integration
> toJSON(integration, pretty = TRUE, auto_unbox = TRUE)
{"id": "36",
"guid": "84f0f0ae-e328-44b0-98ba-aee6e775b5f0",
"created_time": "2024-07-17T21:09:36Z",
"updated_time": "2024-09-15T20:15:59Z",
"name": "Azure",
"description": "New Description",
"template": "azure",
"config": {
"auth_mode": "Confidential",
"client_id": "23a0078b-cd0d-489f-8e00-e5116c71db9b",
"scopes": "2ff814a6-3304-4ab8-85cb-cd0e6f879c1d/.default offline_access",
"tenant_id": "a0b52758-d0b5-4b27-a6c0-13ca07eabdd7"
} }
Discussion
Metadata attributes (id
, guid
, created_time
, updated_time
) and the template
attribute cannot be updated.
See also
- For more details about the data returned in this recipe, Update an OAuth integration 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.