slack-ruby / slack-ruby-bot

The easiest way to write a Slack bot in Ruby.
MIT License
1.12k stars 187 forks source link

not_allowed_token_type error when booting app #241

Closed jillguyonnet closed 9 months ago

jillguyonnet commented 4 years ago

Hi there,

I've had a working bot/app for a while, passed a SLACK_API_TOKEN env var with the bot user token, and just ran into the following issue today after changing some settings (scopes) in the Slack app (in api.slack.com/apps). From the Ruby app logs when trying to start the app:

ERROR -- : not_allowed_token_type (Slack::Web::Api::Errors::SlackError)
/bundle/gems/slack-ruby-client-0.14.5/lib/slack/web/faraday/response/raise_error.rb:13:in `on_complete'
/bundle/gems/faraday-0.17.3/lib/faraday/response.rb:9:in `block in call'
/bundle/gems/faraday-0.17.3/lib/faraday/response.rb:61:in `on_complete'
/bundle/gems/faraday-0.17.3/lib/faraday/response.rb:8:in `call'
/bundle/gems/faraday-0.17.3/lib/faraday/response.rb:8:in `call'
/bundle/gems/faraday-0.17.3/lib/faraday/request/url_encoded.rb:15:in `call'
/bundle/gems/faraday-0.17.3/lib/faraday/request/multipart.rb:15:in `call'
/bundle/gems/faraday-0.17.3/lib/faraday/rack_builder.rb:143:in `build_response'
/bundle/gems/faraday-0.17.3/lib/faraday/connection.rb:387:in `run_request'
/bundle/gems/faraday-0.17.3/lib/faraday/connection.rb:175:in `post'
/bundle/gems/slack-ruby-client-0.14.5/lib/slack/web/faraday/request.rb:26:in `request'
/bundle/gems/slack-ruby-client-0.14.5/lib/slack/web/faraday/request.rb:11:in `post'
/bundle/gems/slack-ruby-client-0.14.5/lib/slack/web/api/endpoints/rtm.rb:42:in `rtm_start'
/bundle/gems/slack-ruby-client-0.14.5/lib/slack/real_time/client.rb:179:in `build_socket'
/bundle/gems/slack-ruby-client-0.14.5/lib/slack/real_time/client.rb:51:in `start!'
/bundle/gems/slack-ruby-bot-0.12.0/lib/slack-ruby-bot/server.rb:35:in `start!'
/bundle/gems/slack-ruby-bot-0.12.0/lib/slack-ruby-bot/server.rb:29:in `block (2 levels) in run'
/bundle/gems/slack-ruby-bot-0.12.0/lib/slack-ruby-bot/server.rb:49:in `handle_exceptions'
/bundle/gems/slack-ruby-bot-0.12.0/lib/slack-ruby-bot/server.rb:27:in `block in run'
/bundle/gems/slack-ruby-bot-0.12.0/lib/slack-ruby-bot/server.rb:26:in `loop'
/bundle/gems/slack-ruby-bot-0.12.0/lib/slack-ruby-bot/server.rb:26:in `run'
/bundle/gems/slack-ruby-bot-0.12.0/lib/slack-ruby-bot/bot.rb:6:in `run'
config.ru:10:in `block (2 levels) in <main>'

I've tried reinstalling/recreating the Slack app, updating gems, no dice. Is it possible that SLACK_API_TOKEN is no longer sufficient as a token?

brax10ward commented 4 years ago

I am also having this issue after upgrading the scopes to slacks new "granulated" approach. There is no longer just a bot scope.

dblock commented 4 years ago

Can someone carefully read https://api.slack.com/docs/token-types#bot and maybe open a ticket with Slack?

AFAIK this was being deprecated and one needs to install apps via oauth workflow and all that. I use https://github.com/slack-ruby/slack-ruby-bot-server for that built on top of this library. The changes probably mean the documentation for slack-ruby-bot is now incorrect regarding tokens, too. Would appreciate if someone could dig it all up and PR the necessary changes.

dblock commented 4 years ago

See https://github.com/slack-ruby/slack-ruby-bot/issues/252#issuecomment-607017869 which is a step-by-step repro of getting to the not_allowed_token_type error. The deployment guide has been updated to describe how to create a "classic" bot in #251.