I'm using slack web api in my application. One of the features that users can do is to create channels directly from the app. I want to show something for the users, who are not granted to create channels in Slack. But I don't understand how can I get this slack permissions from API.
2 Answers
Allow me clarify two concepts within Slack:
In addition to required the correct Oauth scopes (e.g.
channels:write
forchannels.create
) the permission to create a channel is an admin setting of the workspace.The rights of your app are determined both by its scopes AND by the rights of the user that installed your app. But NOT the user that uses your app, e.g. via a slash command.
So you can request the correct scopes with your app but your installing user might not have the right to create channel. Unfortunately there is no API method that will tell you if the user has the right to create channels on a particular workspace.
But at least you can show the user an appropriate error message. channels.create will return the error restricted_action
in case the user is missing the rights.

- 30,467
- 8
- 79
- 114
-
Thank you, looks like I have to show message after user is trying to create message, not before. – Gatilin Maxim Oct 10 '18 at 15:04
You have to do what is called "Oauth." You essentially hit Slack's Oauth API and say, "I have this user." They verify the user is who they say they are using their Slack creds. If their creds work, Slack sends you a token. That token lasts for X amount of time. Usually, you store it and dump it when Slack says it is stale. Docs are below.
https://api.slack.com/docs/oauth
Oauth is used for using third party APIs, but it can also be used for smaller apps to identify their users without having to store personal identifiable information (PII) and passwords. Essentially you would put that work on Facebook or Google or Slack because it is safer and less work for you.

- 3,404
- 3
- 26
- 40
-
I am having problems to see how these general comments about how Oauth works would answer the actual question. Maybe you can rephrase to be more specific? – Erik Kalkoken Oct 09 '18 at 15:37
-
@ErikKalkoken "But I don't understand how can I get this slack permissions from API" they have to be granted permissions through Oauth – Max Baldwin Oct 09 '18 at 15:42
-
-
1This is definitely not an answer to my question, I know how slack oauth works – Gatilin Maxim Oct 10 '18 at 15:03