Skip to content
Docs

SSO Token Exchange

POSThttps://api.vercel.com/v1/integrations/sso/token
During the autorization process, Vercel sends the user to the provider redirectLoginUrl, that includes the OAuth authorization code parameter. The provider then calls the SSO Token Exchange endpoint with the sent code and receives the OIDC token. They log the user in based on this token and redirects the user back to the Vercel account using deep-link parameters included the redirectLoginUrl. Providers should not persist the returned id_token in a database since the token will expire. See Authentication with SSO for more details.
https://api.vercel.com/v1/integrations/sso/token
const response = await fetch('https://api.vercel.com/v1/integrations/sso/token', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"code": "string",
"state": "string",
"client_id": "example_id",
"client_secret": "string",
"redirect_uri": "https://example.com",
"grant_type": "authorization_code"
}),
});
const data = await response.json();
console.log(data);
Response
{
"id_token": "example_id",
"token_type": "string",
"expires_in": "123",
"access_token": "string",
"refresh_token": "string"
}
application/json
codestringRequired
The sensitive code received from Vercel
statestringOptional
The state received from the initialization request
client_idstringRequired
The integration client id
client_secretstringRequired
The integration client secret
redirect_uristringOptional
The integration redirect URI
grant_typestringRequired
The grant type, when using x-www-form-urlencoded content type
200Success
id_tokenstringRequired
token_typestringRequired
expires_innumberOptional
access_tokenstringRequired
refresh_tokenstringOptional
400One of the provided values in the request body is invalid.
403Error
500Error