slack authentication
Get slack api token
To authenticate against your slack, you need to create an api key. There’re various ways of going about this, using legacy tokens, test tokens or a bot.
I generally create a bot. Given you’re likely to use it just to send notifications to slack, rather than consume events from slack, it’s a pretty simple setup just to get your api key.
Remember to invite and add the bot you create to the slack channel(s) to which you want to post. You invite the bot in like you would a normal user.
ensure secrets stay secret
Be safe! Don’t hard-code your api token, don’t check it into a public repo. Here are some tips for handling api tokens from slack.
Do remember not to fling the api key around as a shell argument - it
could very easily leak that way into logs or expose via a ps
. I
generally use one of the pypyr built-in context parsers like
pypyr.parser.jsonfile
or pypyr.parser.yamlfile
, see pypyr built-in
context parsers.