Revoke an Access Token

Revoke an Access Token by ID.

πŸ‘

Permissions Required

You can only revoke an Access Token that you created, unless you are a team administrator. Team admins can revoke all Access Tokens on your Catalytic team.

Method Signature

AccessToken Revoke(Guid id);
async Task<AccessToken> RevokeAsync(Guid id);

Parameters

ParameterTypeDescription
idGuidThe id of the Access Token to revoke
returnsAccessTokenThe revoked Access Token
AccessToken Revoke(string id);
async Task<AccessToken> RevokeAsync(string id);
ParameterTypeDescription
idstringThe id of the Access Token to revoke
returnsAccessTokenThe revoked Access Token

Example

/*
 * This example demonstrates an administrator finding and revoking
 * all the Access Tokens of another user.
 */
using Catalytic.Sdk.Entities;
using System.Collections.Generic;

namespace Catalytic.Sdk.Examples
{
    class Program
    {
        static void Main(string[] args)
        {
            var catalytic = new Catalytic.Sdk.CatalyticClient(AccessToken.Default);
          
            // The default Access Token must belong to a user with admin rights to get
            // or update another user's Access Tokens
            var bobsTokens = catalytic.AccessTokens.Find(
                Where.Owner.Is("[email protected]"));
          
            // Now that we've found all of Bob's Access Tokens, as an admin
            // we can revoke them
            foreach(var token in bobsTokens.AccessTokens)
            {
                catalytic.AccessTokens.Revoke(token.Id);
            }
        }
    }
}