Skip to main content

Endpoint

Authenticates a user with a third-party provider (social login). This endpoint handles both signing in existing users and signing up new users in a single operation.

Request Headers

string
required
Your SuperTokens API key for authentication
string
Core Driver Interface version (e.g., “2.7”, “3.0”, “4.0”, “5.0”)

Request Body

string
required
The identifier for the third-party provider (e.g., “google”, “facebook”, “github”)
string
required
The user’s unique identifier from the third-party provider
object
required
Email information object containing:

Request Example

Response

Success Response

string
Returns "OK" on successful authentication
boolean
true if a new user account was created, false if an existing user signed in
object
User information object containing:
string
The recipe-specific user ID for this login method (CDI 4.0+)

Success Response Example

Error Response

string
Returns "EMAIL_CHANGE_NOT_ALLOWED_ERROR" when email cannot be changed
string
Error reason description

Error Response Example

Behavior Details

Sign Up vs Sign In

This endpoint automatically determines whether to create a new user or sign in an existing user based on:
  1. Existing User: If a user with the same thirdPartyId and thirdPartyUserId exists, the user is signed in
  2. New User: If no matching user exists, a new user account is created

Email Verification

The isVerified flag in the email object controls email verification:
  • true: The email is marked as verified (trusted provider)
  • false: The email requires manual verification
Email verification support was added in CDI version 4.0. For earlier versions, emails are not automatically verified.

Account Linking

When account linking is enabled (CDI 4.0+), this endpoint may:
  • Link the social account to an existing user with the same email
  • Prevent email changes if the email is already associated with another primary user

Multi-tenancy

This API is tenant-specific. The tenant is determined by:
  • The tenantId header or query parameter
  • The default tenant if not specified
Third-party login must be enabled for the tenant. If disabled, the API will return a BadPermissionException.

Version Compatibility

Common Integration Pattern

Create Session

Create a session after authentication

Get User

Retrieve user information

Source Code Reference

Implementation: View source