In order to interact with the Slack API, you will need to set up an authentication token. This token will not be shared, so both partners must follow these steps.
-
Go to https://api.slack.com/apps
- You might have to sign in using your Slack credentials
-
Click the green
Create New Appbutton -
Fill out the details in the modal window
- For the name of your app use
ClassName - YourName - API Project - For the workspace, use the Slack workspace for your cohort
- Click the green
Create Appbutton
- For the name of your app use
-
Click
Add features and functionality, thenPermissions -
Scroll down to
Scopes, and add the following three permissions:chat:write:botchannels:readusers:read
- Click the green
Save Changesbutton
-
Install and authorize the app:
- Scroll to the top of the page and click the green
Install App to Workspacebutton - Check that your app's permissions are correct and click the green
Authorizebutton
- Scroll to the top of the page and click the green
-
You should now see an
OAuth Access Token. Copy this and paste it into your app's.envfile.
- The
.envfile should already be in the provided.gitignore, but it doesn't hurt to double check!
- The
Your application should now be able to access Slack!
To verify that you've set up the Slack token correctly, work with your partner to write a script that does the following:
- Use the
dotenvgem to load environment variables - Use HTTParty to send a
GETrequest to thechannels.listendpoint - Check that the request completed successfully, and print relevant information to the console if it didn't
- Loop through the results and print out the name of each channel
If your tokens are set up correctly, each of you should be able to run this script.


