refresh-token
Method: POST
Path: /auth/refresh-token
Tags: Auth
Summary
Refresh access token
Description
The Refresh Access Token API is an integral component designed to enhance security and user experience. It enables clients to refresh their access tokens seamlessly, extending user sessions without compromising security.
Storefront SDK Usage
SDK Method: sdk.auth.refreshToken()
Example:
typescript
// Refresh access token when it expires
const { data, error } = await sdk.auth.refreshToken({
refresh_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
});
if (error) {
console.error("Token refresh failed:", error.message);
// Redirect to login
} else {
console.log("Token refreshed successfully");
console.log("New access token:", data.access_token);
console.log("New refresh token:", data.refresh_token);
}TypeScript Definition
typescript
"refresh-token": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
"application/json": {
/** @description A string representing the refresh token. */
refresh_token: string;
};
};
};
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
/** @description A descriptive message confirming the success or failure of the operation. */
message: string;
/** @description Indicates whether the request was successful or failure (true for success, false for failure). */
success: boolean;
/** @description An object containing the response content. */
content: {
/** @description It is a string-based token utilized for authentication and authorization. */
access_token: string;
/** @description It is a string-based token designed for refreshing the user's access token. */
refresh_token: string;
};
};
};
};
400: components["responses"]["BadRequest"];
404: components["responses"]["NotFound"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["responses"]["BadRequest"] | BadRequest |
components["responses"]["NotFound"] | NotFound |
Request Body
Content Types: application/json
Responses
200
OK
400
Bad request
404
Requested resource not found
OpenAPI Definition
json
{
"tags": [
"Auth"
],
"operationId": "refresh-token",
"summary": "Refresh access token",
"description": "The Refresh Access Token API is an integral component designed to enhance security and user experience. It enables clients to refresh their access tokens seamlessly, extending user sessions without compromising security.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/refresh-token",
"description": "API reference for the refresh-token operation"
},
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"refresh_token"
],
"properties": {
"refresh_token": {
"description": "A string representing the refresh token.",
"type": "string"
}
}
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"description": "A descriptive message confirming the success or failure of the operation.",
"type": "string"
},
"success": {
"description": "Indicates whether the request was successful or failure (true for success, false for failure).",
"type": "boolean"
},
"content": {
"description": "An object containing the response content.",
"properties": {
"access_token": {
"description": "It is a string-based token utilized for authentication and authorization.",
"type": "string"
},
"refresh_token": {
"description": "It is a string-based token designed for refreshing the user's access token.",
"type": "string"
}
},
"required": [
"access_token",
"refresh_token"
],
"type": "object"
}
}
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"404": {
"$ref": "#/components/responses/NotFound"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "auth",
"x-speakeasy-ignore": false,
"x-speakeasy-name-override": "refreshToken"
}Auto-generated from OpenAPI spec and TypeScript definitions