Skip to main content
import { useState } from 'react';
import { useStytchB2BClient } from '@stytch/react/b2b';

export const DiscoverSSO = () => {
  const stytch = useStytchB2BClient();
  const [connections, setConnections] = useState([]);

  const discoverConnections = async (email) => {
    const response = await stytch.sso.discoverConnections(email);
    setConnections(response.connections);
  };

  return (
    <div>
      <button onClick={() => discoverConnections('user@example.com')}>
        Discover Connections
      </button>
      {connections.map((conn) => (
        <div key={conn.connection_id}>
          {conn.display_name} - {conn.identity_provider}
        </div>
      ))}
    </div>
  );
};
sso.discoverConnections surfaces SSO connections for the end user. It will return all active SSO connections for an end user or, if no active connections are found, it will return all SSO connections that the end user could JIT provision into based on the provided email address.

Response

connections
array
The list of SSO connections discovered for the provided email.
request_id
string
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
status_code
number
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.