MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / integrationAuthorizer

Function integrationAuthorizer

apps/web/pages/api/integration-oauth.ts:13–59  ·  view source on GitHub ↗
(
  community: 'discord' | 'slack',
  accountId: string
)

Source from the content-addressed store, hash-verified

11 process.env.NEXT_PUBLIC_SLACK_CLIENT_ID || '1250901093238.3006399856353';
12
13function integrationAuthorizer(
14 community: 'discord' | 'slack',
15 accountId: string
16) {
17 switch (community) {
18 case 'discord':
19 const discord = getCurrentConfig();
20 return (
21 `https://discord.com/api/oauth2/authorize` +
22 `?client_id=${discord.PUBLIC_CLIENT_ID}` +
23 `&permissions=${discord.permissions}` +
24 `&redirect_uri=${discord.PUBLIC_REDIRECT_URI}` +
25 `&response_type=code` +
26 `&scope=${encodeURIComponent(discord.scope.join(' '))}` +
27 `&state=${accountId}`
28 );
29 case 'slack':
30 const scope = [
31 'channels:history',
32 'channels:join',
33 'channels:read',
34 'incoming-webhook',
35 'reactions:read',
36 'users:read',
37 'team:read',
38 'files:read',
39 'chat:write',
40 'chat:write.customize',
41 ];
42 const user_scope = [
43 'channels:history',
44 'search:read',
45 'users:read',
46 'reactions:read',
47 ];
48 return (
49 'https://slack.com/oauth/v2/authorize' +
50 `?client_id=${SLACK_CLIENT_ID}` +
51 `&scope=${scope.join()}` +
52 `&user_scope=${user_scope.join()}` +
53 `&state=${accountId}` +
54 `&redirect_uri=${REDIRECT_URI_SLACK}`
55 );
56 default:
57 throw new Error('not implemented');
58 }
59}
60
61export default async function handler(
62 request: NextApiRequest,

Callers 1

handlerFunction · 0.85

Calls 1

getCurrentConfigFunction · 0.90

Tested by

no test coverage detected