Viewing Session Information

Problem

You want to view information about a session.

Solution

Use the client.oauth.sessions.get() method to retrieve a session by their unique identifier (GUID).

from posit import connect

GUID = "8f7b293d-2078-439a-bb0e-469e13d4d38d"

client = connect.Client()
session = client.oauth.sessions.get(GUID)
>>> import json
>>> print(json.dumps(session, indent=4))
{
    "id": "13",
    "guid": "8f7b293d-2078-439a-bb0e-469e13d4d38d",
    "user_guid": "2aa02212-e7ee-4689-966f-0bd8a195cfc7",
    "oauth_integration_guid": "153a3d3f-e436-4502-8a5f-01fbb5def977",
    "has_refresh_token": true,
    "created_time": "2024-07-14T21:50:46Z",
    "updated_time": "2024-07-14T21:53:39Z"
}

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 <- "8f7b293d-2078-439a-bb0e-469e13d4d38d"

client <- connect()
session <- client$GET(paste0("v1/oauth/sessions/", GUID))
> library(jsonlite)
> toJSON(session, pretty = TRUE, auto_unbox = TRUE)
{
  "id": "13",
  "guid": "8f7b293d-2078-439a-bb0e-469e13d4d38d",
  "user_guid": "2aa02212-e7ee-4689-966f-0bd8a195cfc7",
  "oauth_integration_guid": "153a3d3f-e436-4502-8a5f-01fbb5def977",
  "has_refresh_token": true,
  "created_time": "2024-07-14T21:50:46Z",
  "updated_time": "2024-07-14T21:53:39Z"
} 

See also

  • For more details about the data returned in this recipe, see Get OAuth session details 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.