Attach OAuth factor

POSThttps://test.stytch.com/v1/oauth/attach

Generate an OAuth Attach Token to pre-associate an OAuth flow with an existing Stytch User. Pass the returned oauth_attach_token to the same provider's OAuth Start endpoint to treat this OAuth flow as a login for that user instead of a signup for a new user.

Exactly one of user_id, session_token, or session_jwt must be provided to identify the target Stytch User.

This is an optional step in the OAuth flow. Stytch can often determine whether to create a new user or log in an existing one based on verified identity provider information. This endpoint is useful for cases where we can't, such as missing or unverified provider information.


Body parameters


provider*string

user_idstring

session_tokenstring

session_jwtstring

Response fields


status_codeint

request_idstring

oauth_attach_tokenstring
curl --request POST \
  --url https://test.stytch.com/v1/oauth/attach \
  -u 'PROJECT_ID:SECRET' \
  -H 'Content-Type: application/json' \
  -d '{
    "provider": "google",
    "user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6"
  }'

RESPONSE

200
{
    "status_code": 200,
    "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
    "oauth_attach_token": "...",
}