Slack Bot Token Authentication: A Practical Guide to OAuth 2.0 Integration
Slack bot tokens authenticate API calls but require channel membership to post messages. This guide covers OAuth 2.0 setup, configuration, and common pitfalls.
02 Oct 2025, 10:04 UTC

The Core Issue: Bot Tokens Need Correct Scopes and Channel Membership
\nSlack bot tokens (xoxb-) authenticate API calls but they still need to be added to specific channels to post messages. A bot with chat:write scope can't post anywhere automatically—it must join each channel with a channel:private grant.
\n\nSetting Up OAuth 2.0 Authentication
\n- \n
- Create a new app at
api.slack.com/apps→ From scratch \n - Under OAuth & Permissions add scopes like
chat:write(post messages) andchannels:read(list channels) \n - Install to workspace copy the Bot User OAuth Token starts with
xoxb-\n
Configuration Example: Posting to a Channel
\nStore the token securely never hardcode it. In a Node.js service:
\n// .env (never commit this file)
SLACK_BOT_TOKEN=xoxb-1234567890-1234567890123-abcdefghijklmnopqrstuvwx
TARGET_CHANNEL=C012AB3CD
\nRun this from your server or local machine with the token loaded from environment variables.
\n\nCommon Mistakes and Limitations
\n- \n
- Channel membership: Bots cannot post to private channels unless explicitly invited or granted channel:private scope. \n
- Scope mismatch: Using chat:write without channels:read means you won't know which channels exist or their IDs. \n
- Token exposure: Committing tokens to version control exposes your workspace to unauthorized actions. \n
- Rate limits: Most Web API methods allow 1 request per second. Exceeding this returns a 429 error. \n
Verifying Your Setup
\nAfter installing your app verify it works:
\n// Test token validity (replace TOKEN with your xoxb- token)
curl -s -X GET https://slack.com/api/conversations.list -H Authorization: Bearer xoxb-... -H Content-Type: application/json | jq .\nIf you see an error like method_not_supported_for_token_type you're using a bot token with an endpoint that requires a user token (xoxp-).
\n\nChecking Bot Channel Membership
\nVerify your bot joined a channel:
\n// Verify bot joined a channel
curl -s -X GET https://slack.com/api/conversation.info?channel=C012AB3CD -H Authorization: Bearer xoxb-... -H Content-Type: application/json | jq .\nLook for is_member true in the response. If false invite the bot manually or via API.
\n\nKey Takeaways
\n- \n
- Bot tokens (xoxb-) authenticate API calls but require channel membership to post. \n
- Store tokens in environment variables or a secrets manager never in source code. \n
- Test with conversations.list first to confirm token validity and discover channel IDs. \n
- Rate limits are strict 1 request per second for most methods. \n