# README
Hosting a Slack App on Google App Engine
This sample builds on part 1 of the slash command tutorial. I recommend starting there before deploying this sample.
Getting the sample code
-
Get the latest sample code.
go get -u github.com/GoogleCloudPlatform/slack-samples/go/command/2-oauth
-
Change to the sample code directory.
cd $GOPATH/src/github.com/GoogleCloudPlatform/slack-samples/go/command/2-oauth
Setup tokens
- Configure the app you created in part 1 by selecting it from the app management page.
- From the Basic information page, copy the Verification token and
write it to
config.go
, as you did in part 1. - Copy the Client ID and write it to
config.go
. - Click the Show button for the Client secret. Copy the secret value
and write it to
config.go
.
Be careful with these tokens. Treat them like you would any other secret token. Do not store tokens in version control or share them publicly.
Setup OAuth
- Click OAuth & permissions item under the features heading on the left navigation.
- Add a new redirect URL. Set it to
https://YOUR-PROJECT.appspot.com/oauth2callback
, replacingYOUR-PROJECT
with your Google Cloud Project ID. - Click the Save URLs button.
Build and Deploy
-
Deploy the app to App Engine.
goapp deploy -application your-project app.yaml
Replace
your-project
with your Google Cloud Project ID. -
If this is not the first App Engine application you have deployed to this project, go to the Google Cloud Platform Console, select version 1 in the App Engine versions and click Migrate traffic to send requests to the deployed version.
Test the app
In your Slack team, write a message with the text /happycloud
. You should see
a happy little quote in response.
Activate distribution
- Go to the Slack app management page for your app.
- Click Manage distribution on the left navigation under the settings header.
- Verify you've completed all the steps in the Share your apps with other teams section.
- Click the Activate public distribution button.
Add the app to a second Slack team
Now that distribution is activated, use the Slack button to share your Slack app with other teams. This lets you test out the app on multiple teams before you submit your app to the Slack app directory.
- Open your App Engine application by going to the URL
https://YOUR-PROJECT.appspot.com
, replacingYOUR-PROJECT
with your Google Cloud Project ID. - Click the Add to Slack button.
- Select a second Slack team to add your app to.
- After the app is added in your second Slack team, write a message with the
text
/happycloud
. You should see a happy little quote in response.
Next steps
- Learn more about using OAuth 2.0 with Slack.
- Explore the other Slack APIs.
- Check out the other Slack samples for Google Cloud Platform