Implement OAuth
- Discovery flow
- Organization flow
The Discovery flow is designed for centralized login pages where users authenticate before selecting which Organization to access.
Start the OAuth flow
Redirect the user to start the OAuth flow. This must be done in the browser:Example URL (Google):Query parameters:
public_token: Your Stytch public tokendiscovery_redirect_url: Where to redirect after OAuth completes
- Google:
/oauth/google/discovery/start - Microsoft:
/oauth/microsoft/discovery/start - GitHub:
/oauth/github/discovery/start - Slack:
/oauth/slack/discovery/start - HubSpot:
/oauth/hubspot/discovery/start
discovery_redirect_url with a token query parameter.Authenticate the OAuth token
After the redirect, exchange the OAuth token for an intermediate session:Parameters:
discovery_oauth_token: The token from the redirect URL query parameter
The Discovery flow returns an
intermediate_session_token which must be exchanged for a full session after the user selects their organization.OAuth scopes
By default, Stytch requests basic scopes (email, profile) from OAuth providers. You can request additional scopes using thecustom_scopes parameter:
Example with custom scopes:
Provider parameters
You can pass provider-specific parameters by prefixing them withprovider_:
Example: