SSO (or Single Sign On) refers to a number of popular authentication frameworks that delegate authentication to an external identity provider (often shortened to IdP) like Okta, Google, or ForgeRock. These external identity providers are owned and managed by IT admins. A user relies on their membership from that provider to sign in instead of creating another password, and developers can enrich their users' experiences with the information shared by the providers.
The Javascript SDK provides methods to start and authenticate SSO flows that you cann connect to your own UI.
Methods
To call these methods, SSO must be enabled in the SDK Configuration page of the Stytch dashboard.
Start SSO flow
The sso.start() method stars a SSO flow by redirecting the browser to Stytch's SSO Start endpoint. The method will also generate a PKCE code_verifier and store it in localstorage on the device.
The authenticate method wraps the authenticate SSO API endpoint which validates the SSO token passed in.
If this method succeeds and the Member is not required to complete MFA, the Member will be logged in, granted an active session, and the session cookies will be minted and stored in the browser.
If this method succeeds and MFA is required, the intermediate session token will be stored in the browser as a cookie.
You can listen for successful login events anywhere in the codebase with the stytch.session.onChange() method or useStytchMemberSession hook if you are using React.