client.defineAuthResolver(slack, async (ctx) => { if (!ctx.account?.id) { return; } const tokens = await clerk.users.getUserOauthAccessToken(ctx.account.id, "oauth_slack"); if (tokens.length === 0) { throw new Error(`Could not find Slack auth for account ${ctx.account.id}`); } return { type: "oauth", token: tokens[0].token, };});
Instance methods
defineAuthResolver()
Define a custom auth resolver for a specific integration
Copy
Ask AI
client.defineAuthResolver(slack, async (ctx) => { if (!ctx.account?.id) { return; } const tokens = await clerk.users.getUserOauthAccessToken(ctx.account.id, "oauth_slack"); if (tokens.length === 0) { throw new Error(`Could not find Slack auth for account ${ctx.account.id}`); } return { type: "oauth", token: tokens[0].token, };});
Auth Resolvers allow you to inject the authentication credentials of your users, using a third-party service like Clerk or Nango or your own custom solution.See our Bring-your-own Auth Guide for more about how this works.
Copy
Ask AI
client.defineAuthResolver(slack, async (ctx) => { if (!ctx.account?.id) { return; } const tokens = await clerk.users.getUserOauthAccessToken(ctx.account.id, "oauth_slack"); if (tokens.length === 0) { throw new Error(`Could not find Slack auth for account ${ctx.account.id}`); } return { type: "oauth", token: tokens[0].token, };});