let's say I've created slack app and I have client id and secret. What is the easiest way to get SLACK_APP_TOKEN in my hands that will be able to create channel?
1 Answers
If you want a proper access token that is related to your Slack App the only way to get it is to install your Slack app with the OAuth process as described here in the Slack documentation. You will need a mini website with a script (e.g. PHP) to perform the installation.
The so called test token will also allow you use the Slack API (e.g. to create a channel), provided that the user that created the test token has that right on your Slack. It is the easiest to obtain, but it will always be linked to a user account, not a Slack app. And you can not request specific scopes for it. So for most applications its better to use a Slack App and get a proper access token by installing it.
If you are looking for an example for an installer script, here is a complete script in PHP. It will run on any webserver that supports PHP. Its very basic, but it will work just fine.

- 30,467
- 8
- 79
- 114
-
Thanks Erik, additional question: let's say I'm publishing my app to the apps directory, how user that wants to use my app should work with this token? is he aware of it or maybe this token is hard coded once the app is loaded to the directory ? – Bazuka Dec 06 '16 at 20:17
-
1Good question. every time a user installs your Slack app into his Slack team an individual access token is generated. You want to store this token in a database, so that your Slack app can access the right token for each Slack team. – Erik Kalkoken Dec 06 '16 at 21:04
-
As I understand the process is : run script inside some web server (let's say localhost) -> this script does rest calls for slack oauth "https://slack.com/api/oauth.access" with client id , secret, and scope -> the script gets as a response code -> the script does additional rest call sending this code and gets token. the script should save this token in DB associated with specific team. so when redirect_uri that was configured in the slack app is being called ? why we need it ? should it be equal to the web server on which the script is running on (on our example localhost) ? – Bazuka Dec 07 '16 at 12:14
-
yes the `redirect_uri` has to point to the location of the installer script, or it will not work. Its a safety measure. Note also, that the webserver needs to be accessible from the Internet (e.g. by Slack), so it will not work if you run it on a local PC behind a router / firewall. – Erik Kalkoken Dec 07 '16 at 12:21
-
thanks Erik for your answers, you have a deep understanding . I've created and installed the app, but channels I created are being created under my user and not by the slack user. I've posted separated question https://stackoverflow.com/questions/41115905/create-slack-channel-using-slack-app appreciate your answer – Bazuka Dec 13 '16 at 07:49