Deleting Sessions

Problem

You want to delete a session.

Solution

Use the session GUID or follow the Finding Sessions recipe to get an integration, then use its delete() method.

from posit import connect

GUID = "d072bd83-b7b9-4064-80e4-d9b5689baf4d"

client = connect.Client()
session = client.oauth.sessions.get(GUID)
session.delete()

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(connectapi)

GUID <- "d072bd83-b7b9-4064-80e4-d9b5689baf4d"

client <- connect()
client$DELETE(paste0("v1/oauth/sessions/", GUID))

A successful response returns a 204 HTTP status code with an empty response.

Response [http://localhost:3939/__api__/v1/oauth/sessions/d072bd83-b7b9-4064-80e4-d9b5689baf4d]
  Date: 2024-09-15 19:40
  Status: 204
  Content-Type: text/plain; charset=utf-8
<EMPTY BODY>

Discussion

All users can delete their own sessions. Only administrators can delete sessions for other users.

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.