如何撤销松弛令牌?

How to revoke a slack token?

我知道 slack API auth.revoke,但是当我使用它时,它不起作用。

我正在通过在我的终端中输入它来尝试以下操作,其中 <TOKEN> 是松弛令牌。

curl -i https://slack.com/api/auth.revoke H "Authorization: Bearer <TOKEN>"

我得到的错误是:

{"ok":false,"error":"not_authed"}curl: (6) Could not resolve host: H
curl: (3) Port number ended with ' '

我期待看到,{"ok":true,"revoked":true}

您收到此响应是因为您在技术上没有向 API 方法提供令牌。在授权 header 中提供令牌仅适用于在 JSON 中支持 POST body 的方法。 auth.revoke 不支持,正如官方文档中所述:

Present arguments as parameters in application/x-www-form-urlencoded querystring or POST body. This method does not currently accept application/json.

这是 curl 的正确语法:

curl https://slack.com/api/auth.revoke -X POST --data "token=TOKEN"