42wim / matterbridge

bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API (mattermost not required!)
Apache License 2.0
6.56k stars 617 forks source link

Not allowed token type for Slack connection #964

Closed glazzara closed 4 years ago

glazzara commented 4 years ago

Describe the bug I followed the creation of a bot token using : https://github.com/42wim/matterbridge/wiki/Slack-bot-setup

I got a xoxb token as expected however I cannot connect to Slack (via RTM) and it retries endlessly.

Expected behavior Being connected to Slack.

Environment

matterbridge.toml [general] RemoteNickFormat="[{LABEL}] @{NICK}" TranslationAttribution=" [translated by :google:]" PreserveThreading=true ShowUserTyping=false MediaDownloadSize=1000000 ShowJoinPart=false NoSendJoinPart=false IconURL="https://github.com/identicons/{NICK}.png"

[slack] [slack.myslack] Token="xoxb-TOKEN"

RemoteNickFormat="{BRIDGE} - @{NICK}"

PrefixMessagesWithNick=true Debug=true

[whatsapp.gui] Number="XXXXXXXXX" SessionFile="session-48111222333.gob" RemoteNickFormat="[{PROTOCOL}] @{NICK}: "

[[gateway]] name="gateway1" enable=true

[[gateway.inout]] account="whatsapp.gui" channel="xxxxxxxxx@g.us"

[[gateway.inout]] account="slack.myslack" channel="test-whatsapp"

Debug output

[2019-12-21T16:41:09+01:00] INFO router: Starting bridge: slack.myslack [2019-12-21T16:41:09+01:00] INFO slack: Connecting using token [2019-12-21T16:41:09+01:00] INFO slack: slack.myslack: joining test-whatsapp (ID: test-whatsappslack.myslack) nlopes/slack2019/12/21 16:41:09 websocket_managed_conn.go:177: Connecting to RTM nlopes/slack2019/12/21 16:41:09 rtm.go:71: Using URL: nlopes/slack2019/12/21 16:41:09 websocket_managed_conn.go:181: Failed to start or connect to RTM: not_allowed_token_type nlopes/slack2019/12/21 16:41:09 websocket_managed_conn.go:147: reconnection 1 failed: not_allowed_token_type reconnecting in 100ms [2019-12-21T16:41:09+01:00] ERROR slack: Connection failed "not_allowed_token_type" &errors.errorString{s:"not_allowed_token_type"} [2019-12-21T16:41:09+01:00] INFO main: Gateway(s) started succesfully. Now relaying messages

dvalfre commented 4 years ago

Similar issue is happening to me. Tried recreating the bot app and permission set on Slack, to no avail. It will be useful if somebody out there with a working configuration can post the permissions the bot has on Slack.

42wim commented 4 years ago

I just set-up a bot from scratch and it still works. You are sure you have the bot scope there?

image

glazzara commented 4 years ago

Hi, Thanks for your tip ! I don't know why but when I created a new application, I got the right permissions and it worked ! In my previous app, I could see the 'bot' scope in bot oauth scopes even though I had created a bot.

42wim commented 4 years ago

Ok, great news, going to close this now as I can't reproduce it and it works for you.

McSneaky commented 4 years ago

@42wim Where can you add bot scope? I have exactly the same problem and here's how it looks for me in Slack app settings: image As far as I understood adding some setting under "Bot Token Scopes" sets "bot" scope automatically. But trying to access Slack with following config:

[slack]
[slack.test]
Token="xoxb-XXX-XXX-XXX"
PrefixMessagesWithNick=true

[general]
RemoteNickFormat="[{PROTOCOL}/{BRIDGE}] <{NICK}> "

[[gateway]]
    name = "mygateway"
    enable=true

    [[gateway.inout]]
    account ="slack.test"
    channel = "bridge"

Throws error:

INFO main:         Running version 1.16.4-dev 4c44515f
INFO main:         WARNING: THIS IS A DEVELOPMENT VERSION. Things may break.
INFO router:       Parsing gateway mygateway
INFO router:       Starting bridge: slack.test 
INFO slack:        Connecting using token
INFO slack:        slack.test: joining bridge (ID: bridgeslack.test)
ERROR slack:       Connection failed "not_allowed_token_type" &errors.errorString{s:"not_allowed_token_type"}
ERROR slack:       Could not retrieve channels: &errors.errorString{s:"missing_scope"}
FATAL main:        Starting gateway failed: Bridge slack.test failed to join channel: could not join channel: &errors.errorString{s:"channel bridge not found"}

Interesting is that it gives not_allowed_token_type and missing_scope

In Slack channel exists and bot is present in there. Using Docker to run it

frabrunelle commented 4 years ago

I get the same error as @McSneaky. Also using Docker to run it. I tried adding additional token scopes but it didn't seem to make a difference.

McSneaky commented 4 years ago

Our team member finally got it to work. Not really 100% sure how, but here are some pointers what he found: https://github.com/slackapi/node-slack-sdk/issues/921#issuecomment-570662540 and https://github.com/nlopes/slack/issues/654

Those might come handy for others too

42wim commented 4 years ago

@McSneaky thanks for the feedback, also added in the https://github.com/42wim/matterbridge/wiki/Slack-bot-setup wiki

ForsakenHarmony commented 4 years ago

Seems like slack changed their permission model, which might require an update from the matterbridge side

ForsakenHarmony commented 4 years ago

I've added some info that you have to create a CLASSIC slack app to the wiki

42wim commented 4 years ago

@ForsakenHarmony thanks :+1:

Souptacular commented 4 years ago

Right now the regular Slack bot set-up won't work at all, only classic does.

Make a bot from scratch following the steps below.

I had to go through the following parts of the set-up in this order:

  1. https://github.com/42wim/matterbridge/wiki/Slack-bot-setup#create-the-classic-slack-app
  2. https://github.com/42wim/matterbridge/wiki/Slack-bot-setup#grant-scopes-and-install-the-slack-app
  3. https://github.com/42wim/matterbridge/wiki/Slack-bot-setup#invite-the-bot-to-channels-synced-with-matterbridge

DO NOT do the Legacy Setup steps.

You will be using an xoxb- once you are done.

42wim commented 4 years ago

@Souptacular thanks for the feedback, I updated the wiki page about it.

RobertDWhite commented 4 years ago

Followed the instructions above, and it kind of works? Getting the same error, but it is also saying the bridge started (config is correct). time="2020-04-12T15:21:03Z" level=info msg="Gateway(s) started succesfully. Now relaying messages" prefix=main time="2020-04-12T15:21:03Z" level=error msg="Connection failed "not_allowed_token_type" &errors.errorString{s:"not_allowed_token_type"}" prefix=slack

Seems strange to me. I went through the steps multiple times with multiple new bots. U am using the "xoxb-" bot token.

matticoli commented 4 years ago

Seems strange to me. I went through the steps multiple times with multiple new bots. U am using the "xoxb-" bot token. @robertomano24

I just went through the process myself and got the same error, it took me a few tries to figure it out. In step 2 of "Create the Classic Slack App" (linked in Souptacular's comment above make sure to use the provided link to create the app, and NOT the "Create App" button.

This seems to be the only way to create a legacy app, which will allow you to create a bot user and add the necessary scopes as described. Make sure not to click any of the "upgrade scopes" prompts during the process or it will break - the scopes in the new "granular permissions" system don't seem to work with matterbridge yet

ForsakenHarmony commented 4 years ago

made it caps and bold in the wiki

htuscher commented 2 years ago

I also get not_allowed_token_type despite having all the scopes configured correctly. I'm trying to connect mattermost and slack.

Fun fact: the mattermost messages are posted to slack, but the slack messages can't be posted back to mattermost. Only then the not_allowed_token_type occurs.

muratgozel commented 1 year ago

Hey, with the current implementation, the only to make this work is to create a Slack App through this link: https://api.slack.com/apps?new_classic_app=1

pge commented 2 months ago

Hey guys! Sorry for the intrusion, but as of right now, classic apps are deprecated and there is no way to bridge to and from Slack. Does anyone have a solution to this?

chatagiri commented 2 months ago

Hey guys! Sorry for the intrusion, but as of right now, classic apps are deprecated and there is no way to bridge to and from Slack. Does anyone have a solution to this?

I have same issue, Shouldn't the issue be reopened since there is currently no way to deal with it?

erkexzcx commented 1 month ago

Slack integration is completely unusable right now...

pm-radez commented 4 weeks ago

Slack integration is completely unusable right now...

May i know when integration will be available?