import { StytchB2BClient } from '@stytch/vanilla-js/b2b';const stytch = new StytchB2BClient('public-token-test-b8c84de4-7d58-4ffc-9341-432b56596862');const session = stytch.session.getSync();
Report incorrect code
Copy
Ask AI
import { StytchB2BClient } from '@stytch/vanilla-js/b2b';const stytch = new StytchB2BClient('public-token-test-b8c84de4-7d58-4ffc-9341-432b56596862');const session = stytch.session.getSync();
Sessions
Get Session
Retrieve session details using the Stytch Vanilla JS SDK
Copy
Ask AI
import { StytchB2BClient } from '@stytch/vanilla-js/b2b';const stytch = new StytchB2BClient('public-token-test-b8c84de4-7d58-4ffc-9341-432b56596862');const session = stytch.session.getSync();
The Stytch SDK caches the Session of the logged-in . sessions.getSync is a synchronous method that fetches the cached session object.If there is no cached data, this method will return null.
The type of authentication factor. The possible values are: email_otp, impersonated, imported, magic_link, oauth, otp, password, recovery_codes, sso, trusted_auth_token, or totp.
The method that was used to deliver the authentication factor. The possible values depend on the type:
email_otp: Only email.
impersonated: Only impersonation.
imported: Only imported_auth0.
magic_link: Only email.
oauth: oauth_google, oauth_microsoft, oauth_hubspot, oauth_slack, or oauth_github.
You may see an ‘exchange’ delivery method when a non-email-verifying OAuth factor originally authenticated in one organization is exchanged for a factor in another organization. This can happen during authentication flows such as session exchange. The non-email-verifying OAuth providers are Hubspot, Slack, and Github. Google is also considered non-email-verifying when the HD claim is empty. The possible exchange values are oauth_exchange_google, oauth_exchange_hubspot, oauth_exchange_slack, or oauth_exchange_github. The final possible value is oauth_access_token_exchange, if this factor came from an access token exchange flow.
A list of the roles associated with the Session.
Members may inherit certain roles depending on the factors in their Session.
For example, some roles may only be active if the member logged in from a specific SAML IDP.