scrapinghub / slackbot

A chat bot for Slack (https://slack.com).
MIT License
1.26k stars 395 forks source link

RTM is deprecated: not_allowed_token_type #217

Open Granitosaurus opened 4 years ago

Granitosaurus commented 4 years ago

Slack is in progress of deprecating RTM protocol in favor of events (which require the bot to roll a whole http server).

To reproduce:

  1. Create new app on https://api.slack.com/apps?new_app=1
  2. Add your oauth scopes: https://api.slack.com/apps/AAAAAAA/oauth?
  3. Run the example code:
slacker.Error: not_allowed_token_type

To fix:

  1. Create app through classic app endpoint: https://api.slack.com/apps?new_classic_app=1
  2. Set "bot" oauth scope.
  3. Add legacy bot user (App Home) section

However this endpoint is deprecated and seems like it will be disabled in favor of the god-awful events api that requires a full web server running waiting for events.
Additionally classic apps are not allowed on slack's app directory.K

a0149659 commented 4 years ago

Hi, I hope this helps you:

I was hoping for slackbot to change with Slack's new events method. I also asked https://github.com/lins05/slackbot/issues/209

The problem is the way slackbot connects to slack.com. I attempted to recode slackbot to work with rtm.connect() as oppose to rtm.start() which is what slackbot uses right now. Its been a good learning experience, so I'm leaving slackbot behind and creating a custom app as it seems its the future of slack.

As a quick solution I moved to errbot https://github.com/errbotio/errbot I found it easier to quickly remake the plugins to work with errbot which supports the rtm.connect() method. Here you can get a legacy token from Slack. https://api.slack.com/custom-integrations/legacy-tokens

I also am a big fan of slackbot, I hope the developers wish to continue working on it.

Granitosaurus commented 4 years ago

@a0149659 Could you elaborate more what you mean? slackbot works fine as long as you establish a legacy app.

The problem I raised in this issue that slack is slackbot raises a vague error, instead it should be capable of understanding that it's connecting to a non-legacy app and inform the user instead.

I don't think supporting events is a good idea. Running a bot as web service is just an absolutely awful idea no matter how you look at it and Slack will most likely not get rid of legacy apps anytime soon.

a0149659 commented 4 years ago

I apologize, I was talking about Slack Enterprise and we found the issue is due to rtm.start vs rtm.connect. I assumed due to the error mentioned and the solution, that you we're facing the same issue. Slackbot doesn't work with Slack Enterprise as is with rtm.start() however you're correct it works fine with Workspaces.

hemna commented 4 years ago

I just tried this bot, and got the same error with a new user bot token.

└─[$] <git:(develop) > python run.py
Traceback (most recent call last):
  File "run.py", line 23, in <module>
    main()
  File "run.py", line 19, in main
    bot = Bot()
  File "/Users/i530566/devel/slack/slackbot/slackbot/bot.py", line 20, in __init__
    self._client = SlackClient(
  File "/Users/i530566/devel/slack/slackbot/slackbot/slackclient.py", line 43, in __init__
    self.rtm_connect()
  File "/Users/i530566/devel/slack/slackbot/slackbot/slackclient.py", line 46, in rtm_connect
    reply = self.webapi.rtm.start(**(self.rtm_start_args or {})).body
  File "/Users/i530566/devel/slack/slackbot/.venv/lib/python3.8/site-packages/slacker/__init__.py", line 818, in start
    return self.get('rtm.start',
  File "/Users/i530566/devel/slack/slackbot/.venv/lib/python3.8/site-packages/slacker/__init__.py", line 118, in get
    return self._request(
  File "/Users/i530566/devel/slack/slackbot/.venv/lib/python3.8/site-packages/slacker/__init__.py", line 102, in _request
    raise Error(response.error)
slacker.Error: not_allowed_token_type