list()
Gets a list of M2M tokens for the given machine. By default, the list is returned in descending order by creation date (newest first). This endpoint can be authenticated by either a Machine Secret Key or by a Clerk .
- When fetching M2M tokens with a Machine Secret Key, only tokens associated with the authenticated machine can be retrieved.
- When fetching M2M tokens with a Clerk Secret Key, tokens for any machine in the instance can be retrieved.
Returns a PaginatedResourceResponse object with a data property containing an array of M2MToken objects and a totalCount property containing the total number of M2M tokens for the machine.
function list(queryParams: GetM2MTokenListParams): Promise<PaginatedResourceResponse<M2MToken[]>>- Name
expired?- Type
boolean- Description
Whether to include expired M2M tokens. Defaults to
false.
- Name
machineSecretKey?- Type
string- Description
The custom machine secret key for authentication. If not provided, the SDK will use the value from the environment variables.
- Name
revoked?- Type
boolean- Description
Whether to include revoked M2M tokens. Defaults to
false.
- Name
subject- Type
string- Description
The machine ID to query M2M tokens by.
Filter by machine ID
Gets a list of M2M tokens for a machine
const machineId = 'mt_123'
const m2mTokens = await clerkClient.m2m.list({
subject: machineId,
})Filter by machine ID, including revoked and expired tokens
Gets a list of M2M tokens for a machine, including revoked and expired ones
const machineId = 'mt_123'
const m2mTokens = await clerkClient.m2m.list({
subject: machineId,
revoked: true,
expired: true,
})Filer by machine ID, including revoked and expired tokens, with pagination
Gets a list of M2M tokens for a machine with pagination
const machineId = 'mt_123'
const m2mTokens = await clerkClient.m2m.list({
subject: machineId,
limit: 20,
offset: 0,
})Backend API (BAPI) endpoint
This method in the SDK is a wrapper around the BAPI endpoint GET/m2m_tokens. See the BAPI reference for more information.
Feedback
Last updated on