如何在谷歌环聊中删除 Webhook 发送的消息

Cha*_*hao 5 hangouts-api hangouts-chat

我跟随传入的 bot python发送带有 webhook 的消息,我想用Method:delete删除它。

但我收到错误 401,以下是错误消息。

{'error': {'code': 401,
           'message': 'Request is missing required authentication credential. '
                      'Expected OAuth 2 access token, login cookie or other '
                      'valid authentication credential. See '
                      'https://developers.google.com/identity/sign-in/web/devconsole-project.',
           'status': 'UNAUTHENTICATED'}}
Run Code Online (Sandbox Code Playgroud)

Webhook 似乎使用密钥和令牌作为授权。但是我无法删除具有相同 url(目标为“data-id”)的消息。

小智 0

您必须已下载凭证文件。如果没有,请按照操作。

下载后,请按照以下步骤生成身份验证令牌。

  1. 设置环境变量

    导出 GOOGLE_APPLICATION_CREDENTIALS=

  2. 在终端上运行此命令。

    gcloud auth 应用程序默认打印访问令牌

  3. 在 Postman -> 授权 -> 类型 OAuth 2.0 -> 访问令牌中使用生成的令牌或在标头中作为

    headers = { 'Content-Type': "application/json", 'Authorization': "Bearer", ... }