Skip to main content
POST
/
api
/
oauth
/
exchange
Exchange OAuth Code for JWT
curl --request POST \
  --url https://api.example.com/api/oauth/exchange \
  --header 'Content-Type: application/json' \
  --data '
{
  "code": "<string>",
  "state": "<string>",
  "error": "<string>",
  "code_verifier": "<string>"
}
'
{
  "access_token": "<string>",
  "user": {
    "id": "<string>",
    "email": "<string>",
    "first_name": "<string>",
    "last_name": "<string>",
    "clerk_user_id": "<string>",
    "is_active": true,
    "is_verified": true
  }
}

Body

application/json

Request to exchange OAuth code for JWT

code
string | null

Authorization code returned by the OAuth provider after user consent

state
string | null

State token from the initial auth request, used for CSRF protection

error
string | null

Error code if OAuth provider returned an error instead of authorization code

code_verifier
string | null

PKCE code verifier that corresponds to the code_challenge sent in the authorization request

Response

Successful Response

Response containing JWT and user info

access_token
string
required
user
UserInfo · object
required

User information in token exchange response