B2B Saas Authentication

/

Frontend SDKs

/

Headless

/

OAuth

/

Start Discovery OAuth Flow

Start Discovery OAuth flow

The oauth.$provider.discovery.start() methods start OAuth flows by redirecting the browser to one of Stytch's OAuth Discovery Start endpoints. The method will also generate a PKCE code_verifier and store it in local storage on the device (See the PKCE OAuth guide for details). If your application is configured to use a custom subdomain with Stytch, it will be used automatically.

  • oauth.google.discovery.start()
  • oauth.microsoft.discovery.start()
  • oauth.hubspot.discovery.start()
  • oauth.slack.discovery.start()

Method parameters


discovery_redirect_urlstring

custom_scopesstring

provider_paramsobject
import { useStytchB2BClient } from '@stytch/react/b2b';

export const Login = () => {
  const stytch = useStytchB2BClient();

  const startOAuth = () =>
    stytch.oauth.google.discovery.start({
      discovery_redirect_url: 'https://example.com/authenticate',
      provider_params: {
        login_hint: 'example_hint@stytch.com',
      },
    });

  return <button onClick={startOAuth}>Log in with Google</button>;
};