Exchange code for tokens
/api/v1/third_party_integrations/oauth/token
Exchange an authorization code for an access token and refresh token.
Server-to-server. Send the code your callback received along with your client_id + client_secret. Returns both tokens — store them in your database, keyed by the installing user. Codes are single-use and expire 10 minutes after consent: a second exchange with the same code returns an error indicating that the code has already been used. If the exchange times out or returns a 5xx, retry it once; if the retry reports the code as already used, the first attempt was processed and no tokens can be recovered — send the user through the install URL again. The token endpoints are not covered by the per-installation API rate limits and do not return 429.
Responses
| Status | When |
|---|---|
200 | Success — tokens issued |
400 | Invalid or expired authorization code |
400 | Code already used (single-use enforcement) |
curl -X POST "https://backend.mysmsgateway.app/api/v1/third_party_integrations/oauth/token" \
-H "Content-Type: application/json" \
-d '{
"grant_type": "authorization_code",
"code": "4f8a7e1d2c9b3a5f6e0d1c2b7a8f9e6d",
"client_id": "<YOUR CLIENT_ID>",
"client_secret": "<YOUR CLIENT_SECRET>",
"redirect_uri": "https://your-app.com/oauth/callback"
}'{
"success": true,
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 86400,
"scopes": [
"contacts.read",
"contacts.write"
]
}
}« Send the user to the install URL
Refresh tokens »
