Skip to main content

Prerequisites

If you haven’t done so already:
  1. Complete the steps in the OAuth configuration guide
  2. Enable the Frontend SDKs in your Stytch Dashboard and enable Create Organizations under “Enabled Methods.”

Add OAuth providers to your UI config

To surface the OAuth providers you wish to support in the UI, add them to the UI config for your authentication flow.
import { B2BProducts, StytchB2B } from '@stytch/react/b2b';

const Login = () => {
  const config = {
    authFlowType: "Discovery", // or "Organization"
    products: [B2BProducts.oauth],
    oauthOptions: {
      providers: [{ type: 'google' }, { type: 'microsoft' }]
    },
  };

  return <StytchB2B config={config} />;
};

export default Login;
You can add multiple OAuth providers by including additional provider objects in the providers array. See the OAuth providers guide for more information on configuring specific providers.

Render the UI component

Render the Stytch UI component on the Redirect URL(s) that you specified in the Stytch Dashboard during the configuration steps. When rendered, the UI component will automatically:
  • Handle the OAuth redirect from Stytch based on the stytch_token_type
  • For Discovery flows, prompt the user with their discovered organizations and handle their selection
  • For Organization-specific flows, log the user in directly

Test your integration

Start your application and test the OAuth flow:
  1. Navigate to your login page
  2. Click on an OAuth provider button (e.g., “Continue with Google”)
  3. Complete the OAuth flow with the provider
  4. Verify that you’re redirected back to your application and authenticated
Use test accounts for your OAuth providers during development to avoid affecting production data.

Next steps