steinarey
steinarey

Reputation: 187

Slack bot scope not updating

I created a Slack bot using the "New App". Set it as a bot and am using the "OAuth Tokens for Your Workspace". With the following scopes under "Bot token scopes":

I added some of these permissions after the initial install (if it matters and you have to refresh something?). The bot is installed to a workspace and I have invited it to a private channel.

Using the example of the Slack API documentation:

from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError

slack_token = SLACK_TOKEN # xoxb-....
client = WebClient(token=slack_token)

try:
    """
    response = client.files_upload(
        channels="C040W4L2HA6",
        file="test.txt",
        title="Test upload"
    )
    """
    response = client.chat_postMessage(
        channel="C040W4L2HA6",
        text="Hello from your app! :tada:"
    )
    
except SlackApiError as e:
    # You will get a SlackApiError if "ok" is False
    assert e.response["error"] 

For both the file write and message examples I get: "ok":false,"error":"missing_scope","needed":"chat:write:bot","provided":"app_mentions:read" but "needed" changes from "chat:write:bot" to "file:write" if I run that part.

Few issues here. I am using the newest version of the client with Python 3.9 and it asks for a permission that is depricated (write:bot is just write now). In both cases it is as if my only active scope is app_mentions:read, nothing else. When I added the other scopes, I clicked "Request to install" and the person reviewing that accepted.

YAML config:

display_information:
  name: BotName
  description: Bot desc.
  background_color: "#000000"
features:
  bot_user:
    display_name: botname
    always_online: false
oauth_config:
  scopes:
    user:
      - chat:write
    bot:
      - app_mentions:read
      - chat:write
      - files:write
      - files:read
      - groups:write
      - chat:write.customize
settings:
  interactivity:
    is_enabled: true
  org_deploy_enabled: false
  socket_mode_enabled: true
  token_rotation_enabled: false

Any ideas?

Upvotes: 0

Views: 1336

Answers (1)

steinarey
steinarey

Reputation: 187

Under "Install app" I had to reinstall it to the workspace, it was not done automatically.

Upvotes: 2

Related Questions