Revoke an Access Token
Revoke an Access Token by ID.
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
revoke(id: string): Promise<AccessToken>;
revoke(id: string, callback: ClientMethodCallback<AccessToken>): void;
revoke(id: string, callback?: ClientMethodCallback<AccessToken>): Promise<AccessToken> | void;
Parameters
Parameter | Type | Description |
---|---|---|
id | string | The id of the Access Token to revoke |
Example
/**
* This example demonstrates revoking an Access Token by Id
*/
const { CatalyticClient } = require('@catalytic/sdk');
const catalytic = new CatalyticClient();
// The default Access Token must have admin rights to get another user's Access Token
// Find all of Bobs Access Tokens
const options = { owner: '[email protected]' };
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;
}
}
// Now that we've found all of Bob's Access Tokens, as an admin we can revoke them
for (const bobsAccessToken of results.getAccessTokens()) {
await catalytic.accessTokens.revoke(bobsAccessToken.getId());
}
Updated almost 4 years ago