B2B Saas Authentication

/

API reference

/

OAuth

/

Discovery

/

Use Microsoft for discovery

Start Microsoft Discovery OAuth flow

GEThttps://test.stytch.com/v1/b2b/public/oauth/microsoft/discovery/start

A client-side endpoint (can only be queried from the user's browser) that starts the Microsoft OAuth flow. This endpoint generates the Microsoft OAuth URL with all required fields and redirects the user to that URL. The user authenticates with Microsoft before getting redirected back to Stytch. After verifying the request, Stytch redirects the user back to the discovery_redirect_url provided.

Scopes

By default our Microsoft OAuth integration includes open_id, email, User.Read, and profile scopes. You may add any additional Microsoft API scopes (see here for a complete list) as a space separated list in the custom_scopes query parameter of /oauth/microsoft/start.

Additional provider parameters

Any parameters that should be forwarded to the OAuth provider can be passed as query parameters with the provider_ prefix. 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. To specify the login_hint parameter in your OAuth request, you'd include provider_login_hint=exampleHint as a query parameter. We recommend consulting each OAuth provider's documentation for a list of supported parameters.

Next steps

Once the user successfully authenticates with Microsoft, they'll be redirected to the redirect URL that you provided at the start of the OAuth flow with a Stytch OAuth token. Collect the token from the URL query parameters, and call Authenticate Discovery OAuth to exchange it for an Intermediate Session Token. Intermediate Session Tokens can be used for various Discovery login flows and are valid for 10 minutes.


Query parameters


public_token*string

discovery_redirect_urlstring

custom_scopesstring

provider_[parameter]string

pkce_code_challengestring

Response fields


status_codeint

request_idstring

redirect_urlstring
curl --request GET \
    --url 'https://test.stytch.com/v1/b2b/public/oauth/microsoft/discovery/start?public_token=PUBLIC_TOKEN'

RESPONSE

302
{
    "status_code": 302,
    "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
    "redirect_url": "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?access_type=offline&client_id=example-client-id&redirect_uri=https%3A%2F%2Fstytch.com%2Fv1%2Foauth%2Foauth-callback-test-d868b16b-3ecd-49ac-7fc6-e3d1051c5d65&response_type=code&scope=openid+email+profile+User.Read&state=example-state",
}