You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed the setup tutorial (created an app, added a bot, etc.), then I copy my Bot User OAuth Access Token to the following code:
import os
import slack
slack_token = os.environ.get("xoxb-THE_REST_OF_AUTH_IS_HERE")
client = slack.WebClient(token=slack_token)
client.chat_postMessage(
channel="#MY_CHANNEL_IS_HERE",
text="Hello from your app! :tada:"
)
...and I'm getting the following error:
raise e.SlackApiError(message=msg, response=self)
slack.errors.SlackApiError: The request to the Slack API failed.
The server responded with: {'ok': False, 'error': 'not_authed'}
How do I "Auth" my bot's token then?
I did see a similar issue from another user, but no answer was provided to fix it.
What type of issue is this? (place an x in one of the [ ])
bug
enhancement (feature request)
question
documentation related
testing related
discussion
Requirements (place an x in each of the [ ])
I've read and understood the Contributing guidelines and have done my best effort to follow them.
Scratch that, I'm using the below code to post messages to my channel:
import requests
import json
web_hook_url = 'https://hooks.slack.com/services/THE_REST_OF_MY_APPS_URL' # Need to encrypt this value in future
slack_msg = {'text': 'Alert from Python'}
requests.post(web_hook_url, data=json.dumps(slack_msg))
importosfromslack_sdkimportWebClientfromslack_sdk.errorsimportSlackApiErrorfromdotenvimportload_dotenvload_dotenv()
key=os.environ.get('token') #token in a .env file client=WebClient(token=key) #or if not in a .env file, (token="xoxb-res_of_the_token")result=client.chat_postMessage(
channel='#push-notifications',
text="Hello world"
)
was trying today and got the error, and after seeing the errors in the docs, it was not getting initialised properly and the getenv was returning a "NoneType" object
had forgotten to add this line:
Description
I followed the setup tutorial (created an app, added a bot, etc.), then I copy my Bot User OAuth Access Token to the following code:
...and I'm getting the following error:
How do I "Auth" my bot's token then?
I did see a similar issue from another user, but no answer was provided to fix it.
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
slackclient version: 2.3.1
python version: 3.6
OS version(s): Windows 10
Steps to reproduce:
Expected result:
To be able to post a message to my Slack channel from my python script.
Actual result:
The mentioned error
Attachments:
The text was updated successfully, but these errors were encountered: