Scheduling infrastructure for absolutely everyone.
Very rudimentary development version of zoom auth
nicolasb5733716decb
diff --git a/.env.example b/.env.exampleindex 60d84bc9552..de845300ed0 100644--- a/.env.example+++ b/.env.example@@ -9,6 +9,10 @@ NEXT_PUBLIC_TELEMETRY_KEY=js.2pvs2bbpqq1zxna97wcml.oi2jzirnbj1ev4tc57c5rMS_GRAPH_CLIENT_ID=MS_GRAPH_CLIENT_SECRET=+# Used for the Zoom integration+ZOOM_CLIENT_ID=+ZOOM_CLIENT_SECRET=+# E-mail settings# Calendso uses nodemailer (@see https://nodemailer.com/about/) to provide email sending. As such we are trying todiff --git a/pages/api/integrations/zoom/add.ts b/pages/api/integrations/zoom/add.tsnew file mode 100644index 00000000000..f07231a9990--- /dev/null+++ b/pages/api/integrations/zoom/add.ts@@ -0,0 +1,29 @@+import type {NextApiRequest, NextApiResponse} from 'next';+import {getSession} from 'next-auth/client';+import prisma from '../../../../lib/prisma';++const client_id = process.env.ZOOM_CLIENT_ID;++export default async function handler(req: NextApiRequest, res: NextApiResponse) {+ if (req.method === 'GET') {+ // Check that user is authenticated+ const session = await getSession({req: req});++ if (!session) { res.status(401).json({message: 'You must be logged in to do this'}); return; }++ // Get user+ const user = await prisma.user.findFirst({+ where: {+ email: session.user.email,+ },+ select: {+ id: true+ }+ });++ const redirectUri = encodeURI(process.env.BASE_URL + '/api/integrations/zoom/callback');+ const authUrl = 'https://zoom.us/oauth/authorize?response_type=code&client_id=' + client_id + '&redirect_uri=' + redirectUri;++ res.status(200).json({url: authUrl});+ }+}diff --git a/pages/api/integrations/zoom/callback.ts b/pages/api/integrations/zoom/callback.tsnew file mode 100644index 00000000000..8195f60c7c1--- /dev/null+++ b/pages/api/integrations/zoom/callback.ts@@ -0,0 +1,34 @@+import type {NextApiRequest, NextApiResponse} from 'next';++const client_id = process.env.ZOOM_CLIENT_ID;+const client_secret = process.env.ZOOM_CLIENT_SECRET;++const scopes = ['meeting:write:admin', 'meeting:write', 'meeting:read:admin', 'meeting:read'];++export default async function handler(req: NextApiRequest, res: NextApiResponse) {+ const { code } = req.query;+ console.log(code);+ // Check that user is authenticated+ /*const session = await getSession({req: req});++ if (!session) { res.status(401).json({message: 'You must be logged in to do this'}); return; }++ // TODO Init some sort of oAuth client here++ // Convert to token+ /*return new Promise( (resolve, reject) => oAuth2Client.getToken(code, async (err, token) => {+ if (err) return console.error('Error retrieving access token', err);++ const credential = await prisma.credential.create({+ data: {+ type: 'google_calendar',+ key: token,+ userId: session.user.id+ }+ });++ res.redirect('/integrations');+ resolve();+ }));*/+ res.redirect('/integrations');+}\ No newline at end of file