Last updated: Jun 08, 2026

Revoking Tokens

Revoking Tokenslink

A Personal Access Token can be revoked at any time, for various reasons.

When to Revoke Tokenslink

Revoke tokens immediately in these situations:

  • Token may have been exposed
  • Integration is decommissioned
  • Security audit requires rotation
  • Unusual API activity detected

How to Revoke a Tokenlink

Contact Infraspeak's support team and they will act immediately.

Immediate Effectlink

Once you revoke a token, it will stop working with immediate effect. This action is irreversible.

Trying to use a revoked token on an API request will result in a 401 Unauthorized response.

Handling Revocation in Your Applicationlink

Prepare your integration to handle token revocation gracefully:

import requests
import logging

logger = logging.getLogger(__name__)

class InfraspeakClient:
    def __init__(self, token):
        self.token = token
        self.base_url = "https://api.infraspeak.com/v3"

    def request(self, method, endpoint, **kwargs):
        response = requests.request(
            method,
            f"{self.base_url}/{endpoint}",
            headers={"Authorization": f"Bearer {self.token}"},
            **kwargs
        )

        if response.status_code == 401:
            error = response.json().get("error", {})
            message = error.get("message", "Authentication failed")

            logger.error(f"Token revoked or invalid: {message}")

            # Notify operations team
            self.notify_token_invalid(message)

            raise TokenRevokedException(message)

        response.raise_for_status()
        return response.json()

    def notify_token_invalid(self, message):
        """Send alert when token becomes invalid."""
        # Implement your notification logic
        # e.g., Slack, email
        pass

class TokenRevokedException(Exception):
    pass