I've added the additional scope :
Both on the slack app GUI as well as in bot.js but still get this error when I call bot.api.groups.create
{ err: 'missing_scope',
data:
{ ok: false,
error: 'missing_scope',
needed: 'groups:write',
provided: 'identify,bot:basic' } }
Seems to be related to #154.
I'm running into the same issue. I'm trying to use the channel:history scope but while my main calls all have it, when i use the bot.api methods it's gone:
bot.api.channels.history({
channel: message.item.channel,
latest: message.item.ts,
count: 1,
inclusive: 1,
}, function(err, response) {
console.log(err, response);
});
returns:
missing_scope { ok: false,
error: 'missing_scope',
needed: 'channels:history',
provided: 'identify,bot:basic' }
I have resorted to including the slack WebClient directly, retrieving the token from storage and then using that instead. But i'd rather just stick to botbit since it's all there already. This works though, so should also work for your group:write scope:
var WebClient = require('@slack/client').WebClient;
var token = process.env.SLACK_API_TOKEN || ''; //from env in this case or your data store
var web = new WebClient(token);
web.channels.history(message.item.channel, {
latest: message.item.ts,
count: 1,
inclusive: 1,
}, function(err, info) {
console.log('message', err, info)
});
@tijs Thanks for the tip I ended up having to resort to a similar measure, hijacking the oAuth.js to store the initial user token somewhere before calling the web api.
@tijs after you changed the scope on your bot, did you reauthorize it for your team? Slack requires this on scope changes.
@peterswimm yes i reinstalled it. the same token works fine when i use the slack WebClient directly. just not when i use the bot.api calls.
Maybe the team scope is not available to the bot api methods? but then i don't know how to use those with just botkit. Maybe i simply shouldn't?
@peterswimm so from our email discussion. if we were to turn this into a feature request it would be that the bot.api methods have access to the app token scope somehow too. or alternatively that there is a web.api / user.api mapping in botkit that would allow us to easily use the web api without having to fallback to the slack api.
if this is considered out of scope that would be fine too but then i would suggest making this more clear in the botkit documentation. A simple way to retrieve the app token for the current team would be nice in that case.
Adding enhancement and documentation tags if the community wants to take a stab at either feature requests.
I was running into the same issue and after spending a good bit of time reading through the source code of the https://github.com/howdyai/botkit/blob/master/lib/Slack_web_api.js file, I was able to come up with this as a workaround:
controller.hears(['hello'], 'direct_message,direct_mention', function(bot, message) {
bot.api.groups.close({
token: bot.config.bot.app_token, // App OAuth Access Token
channel: 'AAAAAAA', // replace this with correct channel ID
}, (err, res) => {
console.log(err, res);
});
};
For calls that require the Slack App OAuth Access Token (not the Bot Token), just add the overriding token to the options argument.
Ah neat! I was hoping something like that would be possible but had not found how yet. Thanks for updating here.
Most helpful comment
I was running into the same issue and after spending a good bit of time reading through the source code of the https://github.com/howdyai/botkit/blob/master/lib/Slack_web_api.js file, I was able to come up with this as a workaround:
For calls that require the Slack App OAuth Access Token (not the Bot Token), just add the overriding
tokento the options argument.