    def delete(self, user_name, token_id):
        """Delete a token"""
        user = self.find_user(user_name)
        if not user:
            raise web.HTTPError(404, f"No such user: {user_name}")
        token = self.find_token_by_id(user, token_id)
        # deleting an oauth token deletes *all* oauth tokens for that client
        client_id = token.client_id
        if token.client_id != "jupyterhub":
            tokens = [
                token for token in user.api_tokens if token.client_id == client_id
            ]
            self.log.info(
                f"Deleting {len(tokens)} tokens for {user_name} issued by {token.client_id}"
            )
        else:
            self.log.info(f"Deleting token {token_id} for {user_name}")
            tokens = [token]
        for token in tokens:
            self.db.delete(token)
        self.db.commit()
        self.set_header('Content-Type', 'text/plain')
        self.set_status(204)
Delete a token
jupyterhub/apihandlers/users.py