Skip to content
API Reference
Slack logo

Slack

Communication

Send messages and interact with Slack workspaces

Adding Slack provisions a resource (the upstream Slack API at https://slack.com/api, with default scopes pre-set) and a provider for Slack’s OAuth issuer - auto-provisioned on first install, or reused if you already connected another Slack resource.

Your application calls Keycard’s token-exchange endpoint with the user’s identity, gets back a token scoped to this resource, and uses it to call Slack directly. Identity, policy, and audit log apply to every exchange - the OAuth client secret stays inside Keycard. Each exchange is recorded in the audit log with the user identity, the resource accessed, and the policy decision.

OAuth permissions Keycard requests on install. Override or add scopes in Console.

chat:write
default
channels:read
default
users:read
default
app_mentions:read
assistant:write
bookmarks:read
bookmarks:write
calls:read
calls:write
canvases:read
canvases:write
channels:history
channels:join
channels:manage
channels:write.invites
channels:write.topic
chat:write.customize
chat:write.public
commands
conversations.connect:manage
conversations.connect:read
conversations.connect:write
datastore:read
datastore:write
dnd:read
emoji:read
files:read
files:write
groups:history
groups:read
groups:write
groups:write.invites
groups:write.topic
im:history
im:read
im:write
im:write.topic
incoming-webhook
links:read
links:write
links.embed:write
lists:read
lists:write
metadata.message:read
mpim:history
mpim:read
mpim:write.topic
pins:read
pins:write
reactions:read
reactions:write
reminders:read
reminders:write
remote_files:read
remote_files:share
remote_files:write
search:read.enterprise
search:read.files
search:read.public
search:read.private
search:read.mpim
search:read.im
search:read.users
team:read
team.billing:read
team.preferences:read
tokens.basic
triggers:read
triggers:write
usergroups:read
usergroups:write
users:read.email
users:write
users.profile:read
workflows.templates:read
workflows.templates:write

Call Slack from your application with a Keycard-issued token scoped to this resource.

After installing Slack, your application exchanges a Keycard-issued access token for a token scoped to this resource. Pass the user’s access token as the subject_token.

from keycardai.oauth import Client, BasicAuth, TokenType
import requests
# Exchange the user's Keycard token for a Slack token.
with Client(
"https://<zone-id>.keycard.cloud",
auth=BasicAuth("<your-client-id>", "<your-client-secret>"),
) as client:
response = client.exchange_token(
subject_token=user_access_token,
subject_token_type=TokenType.ACCESS_TOKEN,
resource="https://slack.com/api",
)
# Call Slack directly with the exchanged token.
r = requests.get(
"https://slack.com/api/<endpoint>",
headers={"Authorization": f"Bearer {response.access_token}"},
)

See the OAuth SDK → Token Exchange reference for the full client API.

Register your OAuth credentials with Keycard so the resource can issue tokens.

  1. Go to the Slack API Dashboard
  2. Click Create New AppFrom scratch
  3. Enter an app name and select the workspace you want to develop against
  4. Click Create App
  1. In OAuth & Permissions, scroll to Redirect URLs
  2. Click Add New Redirect URL
  3. Enter the redirect URI provided by Keycard
  4. Click Save URLs
  1. In Basic Information, scroll to App Credentials
  2. Note the Client ID and Client Secret
  1. Open Keycard Console → your zone → Resources
  2. Click Explore Resources
  3. Find and click Slack in the catalog
  4. In the configuration dialog:
    • Enter the Client ID and Client Secret from your Slack app
    • Review the User scopes - the defaults (chat:write, channels:read, users:read) are pre-populated
  5. Click Add Slack API

After adding the resource, go to the Slack provider settings and expand Advanced options. Slack’s OAuth v2 API uses non-standard parameter names, so you must set the following values:

SettingValue
Scope Parameteruser_scope
Scope Separator, (comma)
Access Token Pathauthed_user.access_token

Common errors when wiring Slack into your zone.

Error: invalid_auth

The token is invalid or has been revoked. Reconnect the provider in Keycard Console. If the issue persists, check that the app is still installed in the workspace.

Error: missing_scope

The token doesn’t have the required scopes. Verify the scopes configured in both Slack’s app settings and your Keycard resource match. You may need to reinstall the app to pick up new scopes.

Error: not_allowed_token_type

You may be using a bot token where a user token is expected, or vice versa. Check the scope type (Bot vs User) in your Slack app configuration.