Search code examples
swiftoauthslack

How can I allow users with their own slack account/company login to their slack account in my app


Everything I have read (e.g. https://api.slack.com/docs/oauth) makes it seem as though I can only build an app that integrates with a Slack team I manage. E.g. I have to create my Slack Client ID .. etc ... and then I can oAuth users for my team.

What I want to do is allow my app's users to login to my app using their Slack login (for their Slack team I do not control or have access to.) I don't want to force my users to generate a Client ID to use my app. I want them to login the same way Google Login or Facebook Login works.

The closest thing I have found is a "login with slack" HTML button, but I'd like to do it in iOS using Swift.

Is that possible?


Solution

  • Thanks to some help from friends it looks like the answer is yes.

    You must first make sure you "Distribute App"

    enter image description here

    Then set up the permissions you require and "install app" (which is a bit not "smart" since you can accidentally add conflicting permissions and get an error when trying to install).

    enter image description here

    Once that is done you will get an Auth Token and can make requests for any user to login using oAuth.

    You can also trigger a sign in request like so:

    https://slack.com/oauth/authorize?client_id=[client id]&scope=identity.basic

    Edit: For future Googlers, Slack now also provides a specific documentation page for this type of OAuth grant/login: Sign in with Slack