Turnkey sessions allow a user to take multiple, contiguous actions in a defined period of time.
get
or list
) requires an organizationId
parameter. Populate that field with the sub-organization’s ID in order to get its data.
X-Session
header, gives permission to perform reads. Note that because this is an activity performed by an end-user, it requires authentication (e.g. via passkey).
If you’d like to do this via our SDK abstractions, you can leverage the login1 method, which creates a CreateReadOnlySession
activity under the hood. It stores the resulting session string in Local Storage2, and subsequent requests to fetch data from Turnkey injects the session stored here at call time3 within @turnkey/sdk-browser
.
CreateReadWriteSession
, get the resulting credential bundle, and decrypt it on the client side using the “TEK”. Upon decryption, the result is a usable Turnkey API key that can be used to make both read and write requests.
Our SDK contains an abstraction called loginWithReadWriteSession. Crucially, it is able to infer the organization (or sub-organization) based on a stamp, and create a read-write session on behalf of that organization. From an end-user experience perspective, this means that a developer can request an end-user’s passkey approval once, and subsequently give that user a read-write session.
Note that loginWithReadWriteSession
stores the resulting credential bundle (returned by Turnkey) in Local Storage. We store this credential bundle in Local Storage as it can be used across various React components and pages – as long as both the target embedded key and credential bundle exist, they can be used as a credential to create Turnkey requests. For details on the shape of this stored artifact, see here.
How can I refresh a session?
How can I delete a session?
How long are sessions?
expirationSeconds
parameter. The default length is 900 seconds (15 minutes).How many session keys can be active at once?
invalidateExisting
parameter for Email Auth and OTP Auth activities. This will clear all existing session keys.Can I use the same sessions implementation for web and mobile?