Find Access Tokens

Search for Access Tokens matching a given name or owner, or page through all of your Access Tokens. Note that the returned Access Tokens will include other metadata but will not include the serialized token string, and therefore cannot be used to authenticate SDK requests. The serialized token string is only available when you first create a new Access Token. As a security measure, only a hash of the serialized token is stored.

👍

Permissions Required

You can only get metadata for Access Tokens that you created, unless you are a team administrator. Team admins can get metadata for all Access Tokens on your Catalytic team.

Method Signature

find(): Promise<AccessTokensPage>;
find(options: FindAccessTokensOptions): Promise<AccessTokensPage>;
find(callback: (err?: Error, accessToken: AccessTokensPage) => any): void;
find(options: FindAccessTokensOptions, callback: (err?: Error, accessToken: AccessTokensPage) => any): void;

Parameters

ParameterTypeDescriptionDefault
optionsobjectOptional The paging options and filter criteria to search by, or null to fetch all Access Tokens.
options.ownerPagingOptionsOptional The email, username, or ID of the user whose Access Tokens should be fetched.
options.querystringOptional A query string to search by. Applies to the name property of Access Tokens
options.pageSizenumberOptional The number of Access Tokens to fetch in a single AccessTokensPage response25
options.pageTokenstringOptional The nextPageToken of a previous find request, used to fetch the next set of results
callback(err?: Error, accessToken: AccessToken) => anyOptional The callback
returnsPromise<AccessTokensPage>The requested page of Access Tokens

Example

/*
 * This example demonstrates an administrator finding and revoking
 * all the Access Tokens of another user.
 */

const { CatalyticClient } = require('@catalytic/sdk');

const catalytic = new CatalyticClient();

const options = { pageSize: 25 };
let hasNextPage = false;

while (hasNextPage) {
    const accessTokensPage = await catalytic.accessTokens.find(options);
    accessTokens.push(...accessTokensPage.accessTokens);
    if (accessTokensPage.nextPageToken) {
        options.pageToken = accessTokensPage.nextPageToken;
    } else {
        hasNextPage = false;
    }
}

// Revoke each access token serially
for (const accessToken of accessTokens) {
    await catalytic.accessTokens.revoke(accessToken.id);
};