Matt Goddard
Matt Goddard

Reputation: 909

missing_scope error when trying to fetch channel history with bot token

When doing the following with Slacks Bolt framework:

app.client.conversations.history({
      token: token,
      channel: channelId,
      latest: messageId,
      count: 1
    })

I'm getting Error: An API error occurred: missing_scope.

I'm passing a Bot token (Which the docs indicated is supported https://api.slack.com/methods/conversations.history) and have already added channels.history and channels.read scopes to my oAuth and permission scope so I'm a little suck.

Has anyone come across this before?

Upvotes: 5

Views: 3587

Answers (1)

Erik Kalkoken
Erik Kalkoken

Reputation: 32698

If you want to pull messages from a public channel with conversations.history your bot token will not work. It only has build-in scopes for direct message channels and scopes can not be added.

From the API documentation page:

Bot user tokens may use this method for direct message and multi-party direct message conversations but lack sufficient permissions to use this method on public and private channels.

From the bot token documentation page:

Bot user tokens can't have resource-based OAuth scopes added to them, any scopes other than bot requested during the OAuth installation flow have no effect on the bot user token

So the solution is to use the Oauth Access Token aka user token with the required scopes.

Upvotes: 4

Related Questions