Reputation: 211
If I run the following script to send a message from slack I get a missing scope error, which I cannot resolve so far!
import logging
logging.basicConfig(level=logging.DEBUG)
from slack import WebClient
from slack.errors import SlackApiError
slack_token = 'xoxb-xxxxxx-xxxxxxxx'
client = WebClient(token=slack_token)
try:
response = client.chat_postMessage(
channel="C018KGV8GHJ",
text="Hello from your app! :tada:"
)
except SlackApiError as e:
#You will get a SlackApiError if "ok" is False
assert e.response["error"] # str like 'invalid_auth', 'channel_not_found'
I receive the following error: 'ok': False, 'error': 'missing_scope', 'needed': 'chat:write:bot', 'provided': 'incoming-webhook'
The script is from the slack webpage.
How can I solve the missing_scope error?
Upvotes: 6
Views: 3941
Reputation: 211
The problem was how I set up the slack API. I reinstalled the API: incoming webhooks needs to be enabled, in permissions: Channel:Read and Chat:Write needs to be activated. Also the API needs to be added to the channel. After this everything worked fine!
Upvotes: 7