Deleting All Sessions for an Integration
Problem
You want to delete all sessions for a given integration.
Solution
Iterate over a list of all existing sessions and delete the ones matching the given integration.
Warning
You must have administrator privileges to use this recipe.
Follow the Finding Sessions recipe to get all existing sessions, then iterate over the list and use the session’s delete()
method to delete the session that matches the integration.
from posit import connect
= "d24b4651-29a5-4555-b0f3-b5989bfe40fe"
INTEGRATION_GUID
= connect.Client()
client = client.oauth.sessions.find(all=True)
session for session in sessions:
if session.oauth_integration_guid == INTEGRATION_GUID:
session.delete()
Follow the Finding Sessions recipe to get all existing sessions, then use the connectapi
client to make a direct call to the sessions endpoint to delete the session that matches the integration.
library(connectapi)
library(glue)
library(purrr)
<- "d24b4651-29a5-4555-b0f3-b5989bfe40fe"
INTEGRATION_GUID
<- connect()
client <- client$GET("v1/oauth/sessions?all=true")
sessions
for (session in sessions) {
if (session$oauth_integration_guid == INTEGRATION_GUID) {
$DELETE(glue("v1/oauth/sessions/{session$guid}"))
client
} }
See also
- For more details about the data returned in this recipe, see Delete an OAuth session 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.