撤销 google 服务帐户访问令牌

Revoke google service account access token

我尝试使用 POST https://oauth2.googleapis.com/revoke?token=ACCESS_TOKEN (documentation)

来撤销服务帐户的令牌

但是它说,

{ "error": "invalid_request", "error_description": "Token is not revocable." }

还尝试了 GET https://accounts.google.com/o/oauth2/revoke?token=ONLINE_ACCESS_TOKEN,这给出了相同的错误消息。

我使用以下函数获取服务帐户的访问令牌。

function getAccessToken() {
 return new Promise(function(resolve, reject) {
  const key = require('../placeholders/service-account.json');
  const jwtClient = new google.auth.JWT(
   key.client_email,
   null,
   key.private_key,
   SCOPES,
   null
  );
  jwtClient.authorize(function(err, tokens) {
   if (err) {
    reject(err);
    return;
   }
   resolve(tokens.access_token);
  });
 });
}

撤销仅适用于 Oauth2 凭据。当用户对您的应用程序进行身份验证时,他们会授予您的应用程序访问其数据的权限。通过撤销该访问权限,您将删除该授权。

服务帐户已手动预授权。您需要从 api 服务帐户被授权的任何内容中删除该授权。