错误:发生 API 错误:invalid_auth

Ali*_*lau 7 javascript node.js slack-api

您好,我正在编写我的松弛机器人,我想在选择后将上一条消息更改为新的变量,这是我在选择后触发的操作:

slackInteractions.action({ type: "static_select" }, (payload, res) => {
  console.log(payload);
  web.chat
    .update({
      token: slackSigningSecret,
      channel: payload.container.channel_id,
      ts: payload.container.message_ts,
      as_user: true,
      text: "Hello World"
    })
    .catch(err => {
      console.log(err);
    });
});
Run Code Online (Sandbox Code Playgroud)

我得到了错误:

Error: An API error occurred: invalid_auth
    at Object.platformErrorFromResult (/home/codex/Documents/dan-bot/node_modules/@slack/web-api/dist/errors.js:50:33)
    at WebClient.apiCall (/home/codex/Documents/dan-bot/node_modules/@slack/web-api/dist/WebClient.js:485:28)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  code: 'slack_webapi_platform_error',
  data: { ok: false, error: 'invalid_auth', response_metadata: {} }
}
Run Code Online (Sandbox Code Playgroud)

这是有效负载:

{
  type: 'block_actions',
  team: { id: '//', domain: '*** },
  user: {
    id: 'U010Q9X59QT',
    username: '**',
    name: '***',
    team_id: '//'
  },
  api_app_id: '///',
  token: '***',
  container: {
    type: 'message',
    message_ts: '1585662258.008100',
    channel_id: '****',
    is_ephemeral: true
  },
  trigger_id: '1038328652789.1035324920279.b84d3403b8e44ab0cd53c997ba8b4c72',
  channel: { id: '***', name: 'directmessage' },
  response_url: 'https://hooks.slack.com/actions/T01119JT287/1040413692903/6TWTQqXhcp453TPREb7uRcPn',
  actions: [
    {
      type: 'static_select',
      action_id: 'wkR',
      block_id: 'LM9',
      selected_option: [Object],
      placeholder: [Object],
      action_ts: '1585662260.040519'
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

作为令牌,我使用我的主要松弛令牌,使用它,我尝试将我选择的变体块更改为另一个块,目前尝试更改为字符串“Hello world”,谢谢转发!

The*_*elo 5

回顾一下他们的chat.update文档,该令牌应该是您在 Oauth & Permissions 选项卡上看到的访问令牌,并且以xoxb或开头xoxp。请在此处查看有关其 Oauth 文档的更多信息:https ://api.slack.com/authentication/oauth-v2