Skip to content

Instantly share code, notes, and snippets.

@kenjij
Last active June 13, 2019 07:33
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenjij/69995fcd00290e062ab8ea343acd5664 to your computer and use it in GitHub Desktop.
Save kenjij/69995fcd00290e062ab8ea343acd5664 to your computer and use it in GitHub Desktop.
Slack access token for bots (OAuth)

Slack OAuth for Bot App

1. Autorization

Open in a web browser: https://slack.com/oauth/authorize?scope=bot&client_id=12345.67890

  • Use Client ID from App Credentials.
  • Use bot for scope.

2. Authorization Code

After authorization, it'll redirect to the configured URI with the code param: https://example.com/?code=12345.67890.1a2b3c4d5e6f7a8b9c0d&state= This is only valid for 10 minutes.

3. Request Access Token

GET: https://slack.com/api/oauth.access?client_id=12345.67890&client_secret=1a2b3c4d5e6f7a8b9c0d&code=12345.67890.1a2b3c4d5e6f7a8b9c0d

  • Use Client ID and Client Secret from App Credentials.
  • Use code from previous step.

Access token will be provided in the JSON response:

{
  "ok":true,
  "access_token":"xoxp-123-456-789-aa11bb22cc",
  "scope":"identify,bot",
  "user_id":"U012ABC",
  "team_name":"Team",
  "team_id":"T012ABC",
  "bot":{
    "bot_user_id":"U456DEF",
    "bot_access_token":"xoxb-123-456-789-xx77yy88zz"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment