> ## Documentation Index
> Fetch the complete documentation index at: https://stytch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Start Discovery OAuth Flow

> Start a discovery OAuth authentication flow using the Stytch Vanilla JS SDK

`oauth.$provider.discovery.start()` starts an OAuth discovery flow by redirecting the browser to one of Stytch's [OAuth Discovery Start](/docs/api-reference/b2b/api/oauth/organization/start-google) endpoints. The method will also generate a PKCE `code_verifier` and store it in local storage on the device (See the [PKCE OAuth guide](/docs/multi-tenant-auth/authentication/oauth/adding-pkce) for details). If your application is configured to use a custom subdomain with Stytch, it will be used automatically.

Use one of the following methods to start an OAuth discovery flow:

* `oauth.google.discovery.start()`
* `oauth.microsoft.discovery.start()`
* `oauth.hubspot.discovery.start()`
* `oauth.slack.discovery.start()`
* `oauth.github.discovery.start()`

### Parameters

<ParamField path="discovery_redirect_url" type="string">
  The URL Stytch redirects to after the OAuth flow is completed. This URL should be a route in your application which will run [`oauth.discovery.authenticate`](./discovery-authenticate) and finish the login.

  The URL must be configured as a Discovery URL in your [Stytch Dashboard](https://stytch.com/dashboard/redirect-urls). If the field is not specified, the default Discovery URL will be used.
</ParamField>

<ParamField path="custom_scopes" type="string">
  A space-separated list of custom scopes that you'd like to include. Note that this list must be URL encoded (e.g. the spaces must be expressed as `%20`).
</ParamField>

<ParamField path="provider_params" type="object">
  An object containing parameters that you'd like to pass along to the OAuth provider. For example, some OAuth providers support a `login_hint` parameter that allows you to pre-populate the OAuth login flow with a suggested email address. We recommend consulting each OAuth provider's documentation for a list of supported parameters. The keys in the `provider_params` object are the parameter names (like `login_hint`), and their values are the data that you'd like to pass along for each parameter (like `example_hint@stytch.com`).
</ParamField>

<Panel>
  <RequestExample>
    ```javascript theme={null}
    import { StytchB2BClient } from '@stytch/vanilla-js/b2b';

    const stytch = new StytchB2BClient('public-token-test-b8c84de4-7d58-4ffc-9341-432b56596862');

    // Start Google Discovery OAuth flow
    stytch.oauth.google.discovery.start({
      discovery_redirect_url: 'https://example.com/authenticate',
    });
    ```
  </RequestExample>
</Panel>
