UNPKG

tiny-essentials

Version:

Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.

30 lines 1.43 kB
/** * Revokes an OAuth2 access token from the Discord API. * * This function makes a `POST` request to the `/oauth2/token/revoke` endpoint to invalidate * a user's access token. This is useful for logout or unlink flows, and requires HTTP Basic Auth * using the application's client ID and client secret encoded in base64. * * @param {string} access_token - The Discord OAuth2 access token to be revoked. * @param {Object} tinyAuth - An object with the client_id and client_secret used to generate the Basic Auth credentials. * @param {string} tinyAuth.client_id - The Discord application client ID. * @param {string} tinyAuth.client_secret - The Discord application client secret. * * @returns {Promise<Record<string, any>>} Resolves when the token is successfully revoked. * The response may not contain any body if successful, so `result.data` may be empty. * * @throws {Record<string, any>} If the request fails, rejects with an error object containing `code` and `message`. * * @example * revokeToken('user-access-token', { * client_id: '1234567890', * client_secret: 'superSecret' * }) * .then(() => console.log('Token revoked')) * .catch(err => console.error('Failed to revoke token:', err)); */ export default function revokeToken(access_token: string, tinyAuth: { client_id: string; client_secret: string; }): Promise<Record<string, any>>; //# sourceMappingURL=revokeToken.d.mts.map