Implementing SSO authentication
Complete config steps
If you haven’t done so already, complete the steps in the guide Getting Started with SSO.
Configure callback
Stytch will make a callback to the Login or Signup Redirect URL that you specified in the Stytch Dashboard in order to securely communicate that the user has successful logged in via SSO.If your Redirect URL is Use the response from Stytch to get or create your internal record of the user and organization, and create a session for the user.
http://localhost:3000/authenticate you would add the following route to your application:Initiate SSO
In order to initiate SSO, you will call the Start SSO Login method from your client. This will automatically redirect the user to the workforce IdP to initiate the SSO authentication.You can test the full SSO flow out by calling the
/sso/start method using the connection_id for the SSO Connection you created earlier and your Stytch public_token from the Stytch Dashboard:Identifying the SSO Connection
Depending on your application, there are a few different ways you might identify the correctconnection_id to use for the sso.start() request.
By Organization
If you already know which Organization the end user is attempting to log into you can fetch the Organization object and prompt the user to select between their active ConnectionsBy Email Address
If you don’t know which Organization the user is trying to access, you can use the Discover SSO Connections method in our headless frontend SDK- Active SSO Registrations (e.g. the user has previously signed in via this connection)
- Active Memberships
- Invites
- Eligible to join by email domain