Reputation: 413
I am developing a Slack app with a slash command. When command is executed, Slack send to my Web API a POST request contains channel ID, user ID, token, etc. I want to send an ephemeral message back to the channel. This API (https://api.slack.com/methods/chat.postEphemeral) requires a token.
Is that the token in the request I received above? If not, how can I get that token?
For more information, the Slack workspace and channel were created by myself.
Reponse from Slack API:
{
"ok": false,
"error": "not_authed",
"warning": "missing_charset",
"response_metadata": {
"warnings": [
"missing_charset"
]
}
}
Upvotes: 1
Views: 1970
Reputation: 32737
The token you receive from the Slack request is a verification token, but you need a user or bot user token for API methods.
The verification token can be used to verify that the request you receive really is from Slack. However that approach is outdated and you should used signed secret instead.
To get a user token you need to install you Slack app to a workspace. This can either be done on the Slack app management page or via an Oauth process if you want to install it on other / multiple workspaces.
However, you do not need to call an API method (or a user token) in order to produce an ephemeral response to a slash command. Simple respond directly to the request from Slack with your message in valid JSON or send your message to the response_url
you got in the request from Slack.
Upvotes: 1