Slack is a messaging platform where teams work together in channels, direct messages, and huddles. Sign in with Slack uses OpenID Connect to let people sign in to other apps with their Slack account, which suits tools built for teams that already work in Slack.
How does the integration work?
You can use the Slack OAuth adapter in Appwrite Auth for user authentication and management. This can be convenient for users because they can start using your app without creating a new account. It can also be more secure, because the user has one less password that could become vulnerable.
Appwrite requests the openid, email, and profile user scopes and reads the user's name and email address from Slack. Slack also shares the user's profile photo, which Appwrite uses for user photos in Appwrite Avatars.
Appwrite doesn't receive a verification status for the email address from Slack, so it stores the address as unverified. If another user in your project already has the same address, Appwrite redirects to your failure URL instead of signing in to that account. To connect Slack to an existing account, have the user sign in first and then start createOAuth2Session from the browser, which links Slack as a new identity.
How to implement
To implement the Slack OAuth adapter in Appwrite Auth, there are several steps you must complete:
Step 1: Create a Slack app
First, head to your Slack apps and click Create New App. Choose to create it from scratch, give it a name, and pick the workspace you'll develop it in.
On the app's Basic Information page, save the Client ID and Client Secret from the App Credentials section. You will add the redirect URL in the next step.
Step 2: Add the Slack OAuth adapter to your Appwrite project
For this step, you must create an account on Appwrite Cloud or self-host Appwrite if you haven't already. In your Appwrite project, head over to the Auth page, open the Settings tab, and click Slack under the OAuth2 Providers section.
Enter the Client ID and Client Secret you saved from Slack, turn the provider on, and click Update.
Copy the Redirect URI shown in the provider settings. It follows this format:
https://<REGION>.cloud.appwrite.io/v1/account/sessions/oauth2/callback/slack/<PROJECT_ID>The URI starts with the API endpoint your app uses, so on self-hosted Appwrite it starts with your own domain. Always copy the exact value from the Console. Back in your Slack app settings, open OAuth & Permissions, add the URI under Redirect URLs, and save.
Step 3: Test the provider
Follow the OAuth 2 login flow to test your provider. Pass OAuthProvider.Slack as the provider when you call createOAuth2Session from a client app or createOAuth2Token from a server. Add your app's domain as a platform in your Appwrite project so Appwrite accepts your success and failure URLs.
Read more about Slack and Appwrite Auth
If you would like to learn more about Slack and Appwrite Auth, we have some resources that you should visit:
