Slack
Get your Slack credentials
To use Slack as a social provider, you need to create a Slack app and get your credentials.
- Go to Your Apps on Slack API and click "Create New App"
- Choose "From scratch" and give your app a name and select a development workspace
- In your app settings, navigate to "OAuth & Permissions"
- Under "Redirect URLs", add your redirect URL:
- For local development:
http://localhost:3000/api/auth/callback/slack
- For production:
https://yourdomain.com/api/auth/callback/slack
- For local development:
- Copy your Client ID and Client Secret from the "Basic Information" page
Slack requires HTTPS for redirect URLs in production. For local development, you can use tools like ngrok to create a secure tunnel.
Configure the provider
To configure the provider, you need to pass the clientId
and clientSecret
to socialProviders.slack
in your auth configuration.
Usage
Sign In with Slack
To sign in with Slack, you can use the signIn.social
function provided by the client. The signIn
function takes an object with the following properties:
provider
: The provider to use. It should be set toslack
.
Requesting Additional Scopes
By default, Slack uses OpenID Connect scopes: openid
, profile
, and email
. You can request additional Slack scopes during sign-in:
Workspace-Specific Sign In
If you want to restrict sign-in to a specific Slack workspace, you can pass the team
parameter:
Using Slack API After Sign In
After successful authentication, you can access the user's Slack information through the session. The access token can be used to make requests to the Slack API:
The Slack provider uses OpenID Connect by default, which provides basic user information. If you need to access other Slack APIs, make sure to request the appropriate scopes during sign-in.