Connecting to Slack from App Connect Enterprise as a Service
You can connect to Slack either from the App Connect Designer page, or when you add an app to a flow.
- OAUTH 2.0 AUTH CODE
- BASIC OAUTH
- Email address: The email address used to log in to Slack.
- Password: The password for the specified email address.
- Complete the connection fields that you see in the App Connect Designer
Applications and APIs page or flow editor. If necessary, work with your
Slack administrator to obtain these values.
- Access Token: Specify the basic access token to be used to authenticate App Connect with
your Slack account. Tip: If you do not already have an access token, you can obtain one by completing the steps in #connect_cloud__d27e80.
- Access Token: Specify the basic access token to be used to authenticate App Connect with
your Slack account.
- Click Connect (and then click Continue to close the message about your Slack account requirements).
How to generate an access token for Slack
The Slack process to generate an access token involves the following steps. Some steps can be completed in several ways, but were tested with the methods described.
- In your web browser, sign in to your Slack account: https://slack.com/signin
- In the web browser, open the Your Apps page https://api.slack.com/apps
- Create an app to get a client ID and client secret. If you already have a suitable app, you can
use the client ID and client secret from that app.To create a new app, complete the following steps:
- Click Create an App
- Specify the following parameters:
- App Name: Type a name to help you identify and manage the app.
- Development Slack Workspace: Select a workspace that the app is to be associated with.
- Click Create App
This opens the Basic information tab for the app
- Define the redirect URL to be used by the authorization process:
- Click the OAuth & Permissions menu option
- Click Add New Redirect URL
- Specify the URL https://www.google.com
- Click Add, and then click Save URLs
Click the Basic Information menu option to return to the Basic information tab, then scroll down to the App Credentials section, from where you can copy the client ID and client secret.
- Use the client ID to get an authorization code (to authorize what App Connect can do with your
Slack account)Tip:
- An authorization code expires 10 minutes after it has been obtained, so be prepared to complete the last step within 10 minutes.
- Copy the following link, and then replace
<client_id>
with the client ID from the previous step.https://slack.com/oauth/authorize?response_type=code&state=123456789&client_id=<client_id>&redirect_uri=https://www.google.com&access_type=offline&scope=identify,channels:read,users:read,users:read.email,chat:write:bot,im:read,mpim:read,files:write:user,files:read,groups:read,usergroups:read,chat:write:user,im:write,mpim:write,search:read
- Copy the link with your client ID and then open that link in a web browser tab/window.
If you see a panel to authorise the app, click Allow
This changes the address of the browser tab/window to the following:https://www.google.com/?code=<Code>&state=123456789
where<Code>
is the authorization code.
- Use the client ID, client secret, and authorization code to get the access tokenTip:
- An authorization code expires 10 minutes after it has been obtained, so be prepared to complete this step within 10 minutes of completing the last step.
- An authorization code can be used only once, so if you encounter a problem in this step (for example, an "internal_error" from Slack) you can repeat the previous step to get an new authorization code.
To get an access token, you submit a POST request with the client ID, client secret, and authorization code to https://slack.com/api/oauth.access. The following example makes use of curl, but instead you can use your preferred REST client with the following parameters:
Parameter Description POST https://slack.com/api/oauth.access Form Fields Value grant_type authorization_code client_id Obtained in step 1 client_secret Obtained in step 1 redirect_uri https://www.google.com code Code value copied from address bar at step 3 Curl command syntax:curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=authorization_code&code=<code>&redirect_uri=https://www.google.com&client_id=<client_id>&client_secret=<client_secret>" https://slack.com/api/oauth.access
- Copy and edit the example curl command, replacing the variables
<code>
,<client_ID>
, and<client_secret>
with your own values obtained in previous steps. - Run the curl command. The response includes the access_token value. Example response:
{"ok":true,"access_token":"yoyp-118877537665-...-81505cf4d20985f7ec5992f2bb352855","scope":"identify,channels:read,files:read,groups:read,im:read,mpim:read,search:read,users:read,users:read.email,usergroups:read,chat:write:user,chat:write:bot,files:write:user,im:write,mpim:write","user_id":"U41AA1W4A","team_id":"T2GRTFRUT","enterprise_id":null,"team_name":"AC Content"}
Copy the access_token value for use in App Connect when connecting to Slack
- If you are already logged in to Slack in the same browser window as App Connect Enterprise as a Service, App Connect connects to that Slack account without prompting you for the email address and password. To connect to a different Slack account, log out from Slack first.
- If you don't have a Slack account, you can create one to try Slack for free.
This creates an account in App Connect.
Before you use the account that is created in App Connect in a flow, rename the account to something meaningful that helps you to identify it. To rename the account on the Applications and APIs page, select the account, open its options menu (⋮), then click Rename Account.