get-anonymous-token
Method: POST
Path: /auth/anonymous
Tags: Auth
Summary
Anonymous user
Description
This API’s focus is on anonymous users who have not undergone the formal account creation process. These anonymous users are associated with a unique ID, ensuring that even in the absence of a fully realized account, there is a distinct and trackable identity for each user. To interact with the system, each anonymous user is issued an access token. This access token plays a dual role in the system: it serves as a means of authenticating the user and it also acts as a tool for authorization, determining what actions the authenticated user is permitted to perform.
Storefront SDK Usage
SDK Method: sdk.auth.getAnonymousToken()
Example:
// Get token for guest browsing
const { data, error } = await sdk.auth.getAnonymousToken();
if (error) {
console.error("Failed to get anonymous token:", error.message);
} else {
console.log("Anonymous token:", data.access_token);
// Store token or proceed with guest operations
}TypeScript Definition
"get-anonymous-token": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
/** @description A string containing a descriptive message related to the success or failure of the anonymous user creation or authentication. */
message: string;
/** @description A boolean value indicates the success or failure of the anonymous user operation.`true` for success `false` for failure. */
success: boolean;
/** @description An object containing the response content. */
content: {
/** @description Information about the user, including their name, email, profile image, etc. */
user: components["schemas"]["AnonymousUser"];
/** @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"];
401: components["responses"]["Unauthorized"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["schemas"]["AnonymousUser"] | AnonymousUser |
components["responses"]["BadRequest"] | BadRequest |
components["responses"]["Unauthorized"] | Unauthorized |
Responses
200
OK
400
Bad request
401
Not authorized for given operation on the Resource
OpenAPI Definition
{
"tags": [
"Auth"
],
"operationId": "get-anonymous-token",
"summary": "Anonymous user",
"description": "This API’s focus is on anonymous users who have not undergone the formal account creation process. These anonymous users are associated with a unique ID, ensuring that even in the absence of a fully realized account, there is a distinct and trackable identity for each user. \nTo interact with the system, each anonymous user is issued an access token. This access token plays a dual role in the system: it serves as a means of authenticating the user and it also acts as a tool for authorization, determining what actions the authenticated user is permitted to perform.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/get-anonymous-token",
"description": "API reference for the get-anonymous-token operation"
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"description": "A string containing a descriptive message related to the success or failure of the anonymous user creation or authentication.",
"type": "string"
},
"success": {
"description": "A boolean value indicates the success or failure of the anonymous user operation.`true` for success `false` for failure.",
"type": "boolean"
},
"content": {
"description": "An object containing the response content.",
"properties": {
"user": {
"description": "Information about the user, including their name, email, profile image, etc.",
"$ref": "#/components/schemas/AnonymousUser"
},
"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": [
"user",
"access_token",
"refresh_token"
],
"type": "object"
}
}
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
}
},
"security": [
{
"X-Api-Key": []
}
],
"x-speakeasy-group": "auth",
"x-speakeasy-ignore": false,
"x-speakeasy-name-override": "getAnonymousToken"
}Auto-generated from OpenAPI spec and TypeScript definitions