如何撤销闲置令牌?

时间:2019-09-10 17:00:19

标签: curl slack slack-api

我知道松弛的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}

1 个答案:

答案 0 :(得分:0)

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

  

application/x-www-form-urlencoded querystring或POST正文中将参数作为参数存在。此方法当前不接受application/json

这是curl的正确语法:

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