Python SDK

Sessions

Read the signed-in user, refresh and end a session with the user's tokens, and list or revoke any user's sessions with the secret key.

scute.sessions works with two kinds of credentials. Some methods take the user's own tokens; others use the app's secret key and need no user session.

With the user's tokens#

scute.sessions.current_user(access_token: str)scute.sessions.refresh(refresh_token: str)scute.sessions.sign_out(access_token: str) -> None
MethodCallNotes
current_userGET /v1/auth/:app_id/current_userThe signed-in user. In a support session the answer also has impersonation.
refreshPOST /v1/auth/:app_id/tokens/refreshSends the refresh token as X-Refresh-Token. Returns new tokens.
sign_outDELETE /v1/auth/:app_id/current_userEnds this session. The user's other sessions stay.

These calls send the access token as X-Authorization. They never send the client IP header.

user = scute.sessions.current_user(access_token)scute.sessions.sign_out(access_token)

A token that Scute no longer accepts raises APIError (for example status 401). To turn that into a verification failure, use scute.tokens.verify(token, remote=True), which raises InvalidToken with reason revoked. See Verify tokens.

With the secret key#

scute.sessions.list(user_id: str)scute.sessions.revoke(user_id: str, session_id: str)
MethodCallNotes
listGET /v1/:app_id/users/:user_id/sessionsThe user's sessions, as a list.
revokeDELETE /v1/:app_id/users/:user_id/sessions/:session_idEnds the session at once.
for s in scute.sessions.list(user_id):    print(s)scute.sessions.revoke(user_id, session_id)

A revoked session's access token still passes local verification until it expires. Routes that must reject it at once verify with remote=True.