mishk0 / slack-bot-api

:rocket: Simple way to control your Slack Bot
MIT License
1.35k stars 176 forks source link

[ERROR] not_allowed_token_type error on new bot app #147

Open loretoparisi opened 4 years ago

loretoparisi commented 4 years ago

I have created a brand new bot app (21 feb 2020). I the put my new bot oauth token in the init:

// Slack bot
                self.bot = new SlackBot({
                    token: self._options.slack.botToken,
                    name: self._options.slack.botName,
                    // (boolean, defaults: false) whether to open websocket connection to listen to incoming messages, 
                    // set to true for one time use
                    disconnect: false
                });

where the bot oauth token starts with xoxb-, but I get the not_allowed_token_type in the event

// slack bot error
                self.bot.on('error', (error) => {
                    error = error || new Error('slack connection error');
                    self.logger.error("Channel slack connection error", error.toString());
                    return reject(error);
                });
sb39 commented 4 years ago

@loretoparisi did you get to know how to overcome this error ?

loretoparisi commented 4 years ago

@sb39 not yet, I have created a brand new app on the 21, according to slack on the 20th the new app oauth token have been deployed, so it should have work...

bettysteger commented 4 years ago

same issue: https://github.com/mishk0/slack-bot-api/issues/145

ntallapa12 commented 4 years ago

I am getting the same error, whats the status on this issue?

thedesignchild commented 4 years ago

Can confirm, same issue here too.. claims are that RTM is not allowed and that the issue can be solved if you make a simple slack app instead of a bot

sb39 commented 4 years ago

I would recommend using Slack Official API, its much more flexible and very well documented

baob commented 4 years ago

Can confirm, same issue here too.. claims are that RTM is not allowed and that the issue can be solved if you make a simple slack app instead of a bot

I can confirm both that it's an existing issue AND that the workarounds suggested are fine. Here's what I said in the README of the app I'm building

Creating the slack app

MUST create CLASSIC slack app here and not the new style granular permissions app. After that create a legacy app user then install the app to the workspace. Then the Bot Oauthh token will work.

Related docs:

loretoparisi commented 4 years ago

Hello, so what I did was this

Then I have set the Bot User OAuth Access Token in the SDK:

self.bot = new SlackBot({
                    token: self._options.slack.botToken,
                    name: self._options.slack.botName,
                    // (boolean, defaults: false) whether to open websocket connection to listen to incoming messages, 
                    // set to true for one time use
                    disconnect: false
                });

and I get that error again:

Error: not_allowed_token_type
    at /Users/loretoparisi/Documents/Projects/node_modules/slackbots/index.js:46:33
    at Array.<anonymous> (/Users/loretoparisi/Documents/Projects/node_modules/vow/lib/vow.js:773:56)
    at callFns (/Users/loretoparisi/Documents/Projects/node_modules/vow/lib/vow.js:24:35)
    at processTicksAndRejections (internal/process/task_queues.js:75:11)

So now my guess is that the classic apps are actually not classic apps anymore. Is there any way to check if the app is actually a classic app?

loretoparisi commented 4 years ago

[UPDATE] Okay I have found the problem. I cannot create a classic app anymore, BTW I had a classic old app (2015). I there fore chose the bot scope (deprecated scope), that is not available anymore to updated scopes apps:

Schermata 2020-04-09 alle 13 54 41

and now it works!

So at least in my Slack, I cannot have not classic apps, but it works with a deprecated app. I would keep it open, until it's not adapted to the new apps. I assume that the deprecation has a deadline, after that this workaround would not work anymore.

Thank you.

baob commented 4 years ago

A very full and clear explanation of how to setup a classic app on slack for RTM (for this workaround) from elsewhere: https://github.com/slackapi/hubot-slack/issues/584#issuecomment-611808704

loretoparisi commented 4 years ago

@baob thank you. A question, maybe related to this classic app setup:

var params = {
     icon_emoji: ':rocket:'
 };
self.bot.postMessageToChannel(self._options.slack.botChannel, 'listening...', params);                    

the emoji does not appear in the slack chat. My fault? Thank you.

baob commented 4 years ago

the emoji does not appear in the slack chat. My fault?

I suspect this s unrelated to the main topic of this thread. Two thoughts. (1) are you sure that emoji is available on your slack workspace ? (2) I remember seeing that initially but don't remember taking any specific action to cure it. Perhaps a caching issue ?

loretoparisi commented 4 years ago

@baob yes I have the :rocket: emoji in the workspace. I have also tried to remove the :

// slack bot ready
self.bot.on('start', () => {
    var params = {
       icon_emoji: 'rocket'
    };
    self.bot.postMessageToChannel(self._options.slack.botChannel, 'listening...', params);
    return resolve(true);
});
loretoparisi commented 4 years ago

I confirm now that the emoji works. The problem happens on slack in Chrome, while on slack mobile I can see emojis. Thanks!

TomKulakov commented 4 years ago

Are you guys ever planning to fix this? A few months later I have the same error after a fresh new project, and creating a new app bot. I was following this tutorial. https://www.freecodecamp.org/news/building-a-slackbot-with-node-js-and-slackbots-js/ "slackbots": "^1.2.0"

utricularian commented 3 years ago

Bumping for visibility. Still cannot set fields

Bear-Coding commented 3 years ago

Are you guys ever planning to fix this? A few months later I have the same error after a fresh new project, and creating a new app bot. I was following this tutorial. https://www.freecodecamp.org/news/building-a-slackbot-with-node-js-and-slackbots-js/ "slackbots": "^1.2.0"

Any fix for this? I was following the same tutorial

esbenvb commented 2 years ago

To anyone coming here:

The tutorial on freecodecamp is based on obsolete Slack APIs and a module that's not supporting the recent versions.

I just wasted time on this module and tutorial as well, it should have an "Unsupported" disclamer in top, IMO.

However, I made something work with Slack's own bolt API.

https://blog.logrocket.com/build-a-slackbot-in-node-js-with-slacks-bolt-api/