/
Contact usSee pricingStart building
    Introduction
    Overview
    Postman
    Users
      Create user
      Search users
      Get user
      Update user
      Exchange primary factor
    • Delete

      • Delete user
        Delete user email
        Delete user phone number
        Delete user WebAuthn registration
        Delete user biometric registration
        Delete user TOTP
        Delete user crypto wallet
        Delete user password
        Delete user OAuth registration
    Magic links
    • Via email

      • Send magic link
        Log in or create user
        Invite
        Revoke pending invite
    • Embeddable

      • Create
      Authenticate
    OAuth
      Attach
      Authenticate
    • Start

      • Google
        Amazon
        Apple
        Bitbucket
        Coinbase
        Discord
        Facebook
        Figma
        GitHub
        GitLab
        Linkedin
        Microsoft
        Salesforce
        Slack
        Snapchat
        TikTok
        Twitch
        Twitter
        Yahoo
    Passwords
      Create
      Authenticate
      Strength check
      Migrate
    • Reset options

      • Password reset by email start
        Password reset by email
        Password reset by existing password
        Password reset by session
    One-time passcodes (OTP)
    • Via SMS

      • Send
        Login or create user
    • Via Whatsapp

      • Send
        Login or create user
    • Via email

      • Send
        Login or create user
      Authenticate
    Session management
      Session object
      Get JWKS
      Get sessions
      Authenticate Session
      Revoke session
      Migrate session
      Attest Session
      Exchange Access Token
    Passkeys & WebAuthn
    • Register

      • Start
        Register
    • Authenticate

      • Start
        Authenticate
      Update
      List WebAuthn Credentials
    Time-based one-time passcodes (TOTP)
      Create
      Authenticate
      Get recovery codes
      Recover
    Crypto wallets
      Authenticate start
      Authenticate
    M2M Authentication
      M2M Client Object
    • Token

      • Get Access Token
        Authenticate Access Token
    • M2M Client

      • Create M2M client
        Get M2M client
        Search M2M clients
        Update M2M client
        Delete M2M client
    • Rotate secret

      • Start secret rotation
        Rotate secret
        Cancel secret rotation
    Connected AppsBeta
      Exchange Authorization Code
      Exchange Refresh Token
    • Tokens

      • Connected App ID Token Object
        Connected App Access Token Object
    • Configuration

      • Get JWKS
        Get OpenID Configuration
    • Methods

      • Introspect Token
        Authenticate Access Token (Local)
        Revoke Token
        Get UserInfo
    • Consent Management

      • Start OAuth AuthorizationComing soon
        Submit OAuth AuthorizationComing soon
        Get Authorized Connected Apps for a User
        Revoke Connected App Access to a User
    • Application Management

      • Dynamic Client Registration
        Create Connected App
        Get Connected App
        Search Connected Apps
        Update Connected App
        Delete Connected App
    • Rotate secret

      • Start secret rotation
        Rotate secret
        Cancel secret rotation
    RBAC
      Resource object
      Role object
      Scope object
      Get RBAC Policy
    User Impersonation
      Authenticate Token
    Resources
      Email templates
      URL validation
      Metadata
      User states
    Errors
      Overview
      Error object
      400
      401
      403
      404
      405
      429
      499
      500
      503
Get support on SlackVisit our developer forum

Contact us

Consumer Authentication

/

API reference

/

Connected Apps

/

Consent Management

/

Submit OAuth Authorization

Submit OAuth Authorization

POST
https://test.stytch.com/v1/idp/oauth/authorize

Completes a request for authorization of a Connected App to access a User's account.

Call this endpoint using the query parameters from an OAuth Authorization request, after previously validating those parameters using the Preflight Check API. Note that this endpoint takes in a few additional parameters the preflight check does not- state, nonce, and code_challenge.

If the authorization was successful, the redirect_uri will contain a valid authorization_code embedded as a query parameter. If the authorization was unsuccessful, the redirect_uri will contain an OAuth2.1 error_code. In both cases, redirect the user to the location for the response to be consumed by the Connected App.

Exactly one of the following must be provided to identify the user granting authorization:

  • user_id
  • session_token
  • session_jwt

If a session_token or session_jwt is passed, the OAuth Authorization will be linked to the user's session for tracking purposes. One of these fields must be used if the Connected App intends to complete the Exchange Access Token flow.


Body parameters


user_id string

The unique ID of a specific User. You may use an external_id here if one is set for the user.


session_token string

The session_token associated with a User's existing Session.


session_jwt string

The session_jwt associated with a User's existing Session.


consent_granted boolean

Indicates whether the user granted the requested scopes.


scopes array[strings]

An array of scopes requested by the client.


client_id* string

The ID of the Connected App client.


redirect_uri* string

The callback URI used to redirect the user after authentication. This is the same URI provided at the start of the OAuth flow. This field is required when using the authorization_code grant.


response_type* string

The OAuth 2.0 response type. For authorization code flows this value is code.


prompt string

Space separated list that specifies how the Authorization Server should prompt the user for reauthentication and consent. Only consent is supported today.


state string

An opaque value used to maintain state between the request and callback.


nonce string

A string used to associate a client session with an ID token to mitigate replay attacks.


code_challenge string

A base64url encoded challenge derived from the code verifier for PKCE flows.


Response fields


request_id string

Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.


redirect_uri string

The callback URI used to redirect the user after authentication. This is the same URI provided at the start of the OAuth flow. This field is required when using the authorization_code grant.


authorization_code string

A one-time use code that can be exchanged for tokens.

const stytch = require('stytch');

const client = new stytch.Client({
  project_id: 'PROJECT_ID',
  secret: 'SECRET',
});

const params = {
  consent_granted: true,
  scopes: ["openid"],
  client_id: "connected-app-test-d731954d-dab3-4a2b-bdee-07f3ad1be888",
  redirect_uri: "https://app.example/oauth/callback",
  response_type: "code",
};

client.idp.oauth.authorize(params)
  .then(resp => { console.log(resp) })
  .catch(err => { console.log(err) });
RESPONSE 200
200
​
{
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "redirect_uri": "https://example.com/callback",
  "authorization_code": "example-authorization-code"
}
RESPONSE 401
200
​
{
  "status_code": 401,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "error_type": "unauthorized_credentials",
  "error_message": "Unauthorized credentials.",
  "error_url": "https://stytch.com/docs/api/errors/401"
}
RESPONSE 429
200
​
{
  "status_code": 429,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "error_type": "too_many_requests",
  "error_message": "Too many requests have been made.",
  "error_url": "https://stytch.com/docs/api/errors/429"
}
RESPONSE 500
200
​
{
  "status_code": 500,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "error_type": "internal_server_error",
  "error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.",
  "error_url": "https://stytch.com/docs/api/errors/500"
}