I have made a slack app in which I have a bot. I have selected channels:history, channels:read, channels:write under my permission scope, and also I have passed scopes
"scope":"bot channel:history channel:read channel:write"
while doing my oauth2 verification (using python), and I got a response where the scope is
"scope":"identify,bot,channels:history,channels:read,channels:write"
along with client and bot access tokens.
Now when I do an api call to fetch history of a channel in which my bot is invited to, I get
{
ok: false,
error: 'missing_scope',
needed: 'channels:history',
provided: 'identify,bot:basic'
}
Can someone please tell me where I am going wrong. How can I PROVIDE the channels:history scope in my api call. This is really driving me nuts. Should I be using the client access token, ie xoxp-xxxx, instead of bot token, ie xoxb-xxxx ?'
Thanks!
You can select the scopes to add to your app by heading over to the OAuth & Permissions sidebar. Scroll down to the Scopes section and click to Add an OAuth Scope. For example, try adding the chat:write scope to your Bot Token. It'll allow your app to post messages!
OAuth 2.0 scopes provide a way to limit the amount of access that is granted to an access token. For example, an access token issued to a client app may be granted READ and WRITE access to protected resources, or just READ access. You can implement your APIs to enforce any scope or combination of scopes you wish.
There are two ways for your app to integrate with Slack so that users can initiate and deal with Calls within Slack. One way for a user to initiate your app is via a Slash command—for example, by typing /mycallapp into the message composer. The other way for a user to initiate your app is directly via the Call icon.
Visit the App Directory at my.slack.com/apps/manage on your desktop. Click Edit configuration next to the integration. On the configuration page, click Regenerate below the current token. This is the new token that you can use anywhere you need it.
For people having this problem in the future;
your integrated bot has full access to the slack api, whereas a bot in a slack app don't, as it will used publicly. When you successfully finish oauth2, you should get 2 tokens, user access token
and bot token
. The user token
is used to read history from any channel/groups, and the bot access token
is used to write to them. This means you constantly have to be switching from user token
to bot access token
in your app.
Also, remember that bot-user MUST be a member of a private channel which you want him to connect to.
Hope that helps.
Ps, if any found a better way going about this, feel free to answer below.
Since you did not mention it: You also need to specify all required scopes on the admin page for your Slack app under "Oauth & Permission Scopes".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With