Authentication flow
Before you begin, make sure you’ve completed the SSO provider setup steps.
Overview
- Headless frontend SDK
- Backend SDK
This guide walks through integrating SSO using Stytch’s headless frontend SDKs. This approach gives you complete control over your UI while handling authentication logic on the frontend.Both and Organization-specific authentication flows are supported.
- Discovery authentication
- Organization-specific authentication
The Discovery flow is designed for situations where end users are signing up or logging in from a central landing page, and have not specified which they are trying to access.
Prerequisites
- Complete the steps in the SSO provider setup guide
- Enable the Frontend SDKs in your Stytch Dashboard
Implementation
Discover available SSO Connections
If you have a centralized login page, prompt the user for their email and call The
sso.discoverConnections.sso.discoverConnections() method returns an array of SSO Connections. Use the display_name and idp_type to render the available options, then pass the selected connection_id into the next step.Start the SSO flow
Use the selected The user will be redirected to their IdP to authenticate.
connection_id to initiate the SSO flow.Handle the SSO callback
After the SSO handshake, Stytch redirects to your Login or Signup Redirect URL with a token in the URL. Call The Stytch frontend SDK will store
sso.authenticate to finish the login process.stytch_session_token and stytch_session_jwt in cookies for you. See session cookie management.