0

两年前,有人问是否可以通过 Gitlab API 以编程方式撤销访问令牌。当时的答案是否定的。我没有找到最近的信息来确认或拒绝这仍然是正确的。

我希望在 Python 的 http 请求库中使用类似的东西:

 headers = {'Authorization':  clientSecret}
 res = gitlab.post("https://gitlab.com/oauth/revoke", headers=headers, data={
            'client_id': clientID,
            'access_token': accessToken
        })
print(res.text)

然而,响应是空的,有不同的变化。

4

1 回答 1

0

根据此处的信息,似乎完全有可能撤销访问令牌。这有效:

 payload = {"token": accessToken,
            "token_type_hint": "refresh_token"
        }
 auth = HTTPBasicAuth(clientID, clientSecret)
 res = requests.post("https://gitlab.com/oauth/revoke",
                    data=payload,
                    auth=auth,
                    )
于 2021-04-22T17:16:30.290 回答