(authentication)
- exchangeSsoToken - SSO Token Exchange
- listAuthTokens - List Auth Tokens
- createAuthToken - Create an Auth Token
- getAuthToken - Get Auth Token Metadata
- deleteAuthToken - Delete an authentication 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. This is used to verify the identity of the user during the Open in Provider flow. Providers should not persist the returned id_token
in a database since the token will expire.
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel();
async function run() {
const result = await vercel.authentication.exchangeSsoToken({
code: "<value>",
clientId: "<id>",
clientSecret: "<value>",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { VercelCore } from "@vercel/sdk/core.js";
import { authenticationExchangeSsoToken } from "@vercel/sdk/funcs/authenticationExchangeSsoToken.js";
// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore();
async function run() {
const res = await authenticationExchangeSsoToken(vercel, {
code: "<value>",
clientId: "<id>",
clientSecret: "<value>",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
models.ExchangeSsoTokenRequestBody | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.ExchangeSsoTokenResponseBody>
Error Type | Status Code | Content Type |
---|---|---|
models.VercelBadRequestError | 400 | application/json |
models.VercelNotFoundError | 404 | application/json |
models.SDKError | 4XX, 5XX | */* |
Retrieve a list of the current User's authentication tokens.
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await vercel.authentication.listAuthTokens();
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { VercelCore } from "@vercel/sdk/core.js";
import { authenticationListAuthTokens } from "@vercel/sdk/funcs/authenticationListAuthTokens.js";
// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await authenticationListAuthTokens(vercel);
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.ListAuthTokensResponseBody>
Error Type | Status Code | Content Type |
---|---|---|
models.VercelBadRequestError | 400 | application/json |
models.VercelForbiddenError | 401 | application/json |
models.SDKError | 4XX, 5XX | */* |
Creates and returns a new authentication token for the currently authenticated User. The bearerToken
property is only provided once, in the response body, so be sure to save it on the client for use with API requests.
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await vercel.authentication.createAuthToken({
teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
slug: "my-team-url-slug",
requestBody: {
name: "<value>",
},
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { VercelCore } from "@vercel/sdk/core.js";
import { authenticationCreateAuthToken } from "@vercel/sdk/funcs/authenticationCreateAuthToken.js";
// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await authenticationCreateAuthToken(vercel, {
teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
slug: "my-team-url-slug",
requestBody: {
name: "<value>",
},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
models.CreateAuthTokenRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.CreateAuthTokenResponseBody>
Error Type | Status Code | Content Type |
---|---|---|
models.VercelBadRequestError | 400 | application/json |
models.VercelForbiddenError | 401 | application/json |
models.SDKError | 4XX, 5XX | */* |
Retrieve metadata about an authentication token belonging to the currently authenticated User.
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await vercel.authentication.getAuthToken({
tokenId: "5d9f2ebd38ddca62e5d51e9c1704c72530bdc8bfdd41e782a6687c48399e8391",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { VercelCore } from "@vercel/sdk/core.js";
import { authenticationGetAuthToken } from "@vercel/sdk/funcs/authenticationGetAuthToken.js";
// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await authenticationGetAuthToken(vercel, {
tokenId: "5d9f2ebd38ddca62e5d51e9c1704c72530bdc8bfdd41e782a6687c48399e8391",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
models.GetAuthTokenRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.GetAuthTokenResponseBody>
Error Type | Status Code | Content Type |
---|---|---|
models.VercelBadRequestError | 400 | application/json |
models.VercelForbiddenError | 401 | application/json |
models.VercelNotFoundError | 404 | application/json |
models.SDKError | 4XX, 5XX | */* |
Invalidate an authentication token, such that it will no longer be valid for future HTTP requests.
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await vercel.authentication.deleteAuthToken({
tokenId: "5d9f2ebd38ddca62e5d51e9c1704c72530bdc8bfdd41e782a6687c48399e8391",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { VercelCore } from "@vercel/sdk/core.js";
import { authenticationDeleteAuthToken } from "@vercel/sdk/funcs/authenticationDeleteAuthToken.js";
// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await authenticationDeleteAuthToken(vercel, {
tokenId: "5d9f2ebd38ddca62e5d51e9c1704c72530bdc8bfdd41e782a6687c48399e8391",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
models.DeleteAuthTokenRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.DeleteAuthTokenResponseBody>
Error Type | Status Code | Content Type |
---|---|---|
models.VercelBadRequestError | 400 | application/json |
models.VercelForbiddenError | 401 | application/json |
models.VercelNotFoundError | 404 | application/json |
models.SDKError | 4XX, 5XX | */* |