`'error': 'not_allowed_token_type'` when using `xoxp` token
See original GitHub issueHello everyone! I’m having this error with my Slack app/bot that’s preventing it from functioning at all. The error message itself is the same as (or at least very similar to) all the RTM-related problems (like this and this) that were caused by an API change in December 2019.
However, my bot was created less than four months ago (April 2022), and I set it up using the Events API and Socket Mode. Also, as @srajiang said (and as is mentioned in multiple other places), the Events API is a replacement for the RTM API, and so doesn’t use it. Hence, this is not a duplicate of #584. The bot worked great until I discovered this error today, when I tried to start it up again after it hadn’t been running for a month or two.
The Slack SDK version
slack-bolt==1.13.0
slack-sdk==3.15.2
Python runtime version
Python 3.8.10
OS info
Ubuntu 20.04.4 LTS
Steps to reproduce:
Here’s the code to reproduce the problem (after following the setup steps in the tutorial):
app.py
(there’s literally nothing else in the directory except .git/ and .gitignore)
import os
from slack_bolt import App
from slack_bolt.adapter.socket_mode import SocketModeHandler
# The app
app = App(token=os.environ["SLACK_BOT_TOKEN"])
# Start the app
if __name__ == "__main__":
SocketModeHandler(app, os.environ["SLACK_APP_TOKEN"]).start()
- Make a new Slack App with Socket Mode and Event subscriptions on
- Change to the app directory and run
python3 app.py
Expected result:
As per the tutorial and past experience, the app should output that it’s running properly.
Actual result:
This error message shows up instead:
Failed to retrieve WSS URL: The request to the Slack API failed. (url: https://www.slack.com/api/apps.connections.open)
The server responded with: {'ok': False, 'error': 'not_allowed_token_type'}
Traceback (most recent call last):
File "app.py", line 11, in <module>
SocketModeHandler(app, os.environ["SLACK_APP_TOKEN"]).start()
File "/home/user/.local/lib/python3.8/site-packages/slack_bolt/adapter/socket_mode/base_handler.py", line 46, in start
self.connect()
File "/home/user/.local/lib/python3.8/site-packages/slack_bolt/adapter/socket_mode/base_handler.py", line 31, in connect
self.client.connect()
File "/home/user/.local/lib/python3.8/site-packages/slack_sdk/socket_mode/builtin/client.py", line 165, in connect
self.wss_uri = self.issue_new_wss_url()
File "/home/user/.local/lib/python3.8/site-packages/slack_sdk/socket_mode/client.py", line 61, in issue_new_wss_url
raise e
File "/home/user/.local/lib/python3.8/site-packages/slack_sdk/socket_mode/client.py", line 48, in issue_new_wss_url
response = self.web_client.apps_connections_open(app_token=self.app_token)
File "/home/user/.local/lib/python3.8/site-packages/slack_sdk/web/client.py", line 1502, in apps_connections_open
return self.api_call("apps.connections.open", http_verb="POST", params=kwargs)
File "/home/user/.local/lib/python3.8/site-packages/slack_sdk/web/base_client.py", line 145, in api_call
return self._sync_send(api_url=api_url, req_args=req_args)
File "/home/user/.local/lib/python3.8/site-packages/slack_sdk/web/base_client.py", line 182, in _sync_send
return self._urllib_api_call(
File "/home/user/.local/lib/python3.8/site-packages/slack_sdk/web/base_client.py", line 316, in _urllib_api_call
return SlackResponse(
File "/home/user/.local/lib/python3.8/site-packages/slack_sdk/web/slack_response.py", line 205, in validate
raise e.SlackApiError(message=msg, response=self)
slack_sdk.errors.SlackApiError: The request to the Slack API failed. (url: https://www.slack.com/api/apps.connections.open)
The server responded with: {'ok': False, 'error': 'not_allowed_token_type'}
Any ideas about what’s going wrong, and how to fix it? If you need any more information, I will provide it. Thanks for your time!
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Related StackOverflow Question
@srajiang Oops… well, it turned out I had not stored the token in a complete form. I found another place where it was complete, and, well, that fixed it. Sorry to trouble you! I’ll close this issue now. Thanks again for your help and time! I wish I could think of these things before I post issues, but I guess my brain won’t let me
¯\_(ツ)_/¯.All good @SamMatzko - Thanks for stopping by, and glad we were able to get to the bottom if it!