new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Better Auth · Authentication · all subjects

social sign-on/slack

13 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Slack OAuth sign-in call

To sign in with Slack, call authClient.signIn.oauth2 with providerId "slack" and a callbackURL. Example: ```ts const response = await authClient.signIn.oauth2({ providerId: "slack", callbackURL: "/dashboard", }) ```

Slack OAuth pre-configured provider setup example

To use Slack as an OAuth provider, import slack from 'better-auth/plugins' and configure it with clientId and clientSecret. Example: ```ts import { betterAuth } from "better-auth" import { genericOAuth, slack } from "better-auth/plugins" export const auth = betterAuth({ plugins: [ genericOAuth({ config: [ slack({ clientId: process.env.SLACK_CLIENT_ID, clientSecret: process.env.SLACK_CLIENT_SECRET, }), ], }), ], }) ```

Slack requires HTTPS in production

Slack requires HTTPS for redirect URLs in production environments. For local development, tools like ngrok can be used to create a secure tunnel.

Slack configuration with clientId and clientSecret

To configure Slack provider in auth configuration, pass clientId and clientSecret to socialProviders.slack in the betterAuth configuration object.

Slack app creation steps

To create a Slack app for authentication: go to Your Apps on Slack API (https://api.slack.com/apps), click 'Create New App', choose 'From scratch', give your app a name and select a development workspace.

Slack sign-in configuration example

Example Slack provider configuration: ```ts import { betterAuth } from "better-auth" export const auth = betterAuth({ socialProviders: { slack: { clientId: process.env.SLACK_CLIENT_ID as string, clientSecret: process.env.SLACK_CLIENT_SECRET as string, }, }, }) ```

Sign in with Slack using client

To sign in with Slack, use the signIn.social function with provider set to 'slack': ```ts import { createAuthClient } from "better-auth/client"; const authClient = createAuthClient(); const signIn = async () => { const data = await authClient.signIn.social({ provider: "slack" }); }; ```

Slack default OpenID Connect scopes

By default, Slack provider uses OpenID Connect scopes: openid, profile, and email.

Slack additional scopes during sign-in

Additional Slack API scopes can be requested during sign-in by passing a scopes array to signIn.social: ```ts const signInWithSlack = async () => { await authClient.signIn.social({ provider: "slack", scopes: ["channels:read", "chat:write"], }); }; ```

Slack workspace-specific sign-in configuration

To restrict sign-in to a specific Slack workspace, pass the team parameter with the Slack workspace ID: ```ts socialProviders: { slack: { clientId: process.env.SLACK_CLIENT_ID as string, clientSecret: process.env.SLACK_CLIENT_SECRET as string, team: "T1234567890", }, } ```

Slack redirect URL for local development

For local development with Slack provider, the redirect URL should be http://localhost:3000/api/auth/callback/slack

Access Slack user information after authentication

After successful authentication, the user's Slack ID can be accessed through the session. The access token is stored securely on the server and can be used to make requests to the Slack API.

Slack redirect URL for production

For production with Slack provider, the redirect URL should be https://yourdomain.com/api/auth/callback/slack

Give your agent this brain