* start webex app creation * webex integration wip * fix lint errors * fix lint errors * add webex env vars in appStore.example * webex app wip * fix lint errors * edit webex oauth scopes * add location in webex app config * add site url placeholder and regex in webex config location * debug translateEvent * fix utc formatting for event start time, add test boilerplate for webex, add envs * fix location and datetime formatting * get correct videoCredentials for deleteMeeting * Move webex specific readme content to webex README * Fix app not visible in app-store * Delete setup route * add webex icon * delete prev icon * webex api fix * add app screenshots * Revert tests changes as they dont run * Use config instead of hardcoding vales * Update README * Remove all env variables related to WEBEX app. They can be added through settings->admin->apps interface * update from origin * fix icon path * update webex readme * Update yarn.lock * update webex readme * Remove unnecessary URL from webex * revert changes in cancel booking handler * simply webex zod schemas, logs for debugging --------- Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import type { NextApiRequest } from "next";
|
|
import { stringify } from "querystring";
|
|
|
|
import { WEBAPP_URL } from "@calcom/lib/constants";
|
|
import { defaultHandler, defaultResponder } from "@calcom/lib/server";
|
|
import prisma from "@calcom/prisma";
|
|
|
|
import config from "../config.json";
|
|
import { getWebexAppKeys } from "../lib/getWebexAppKeys";
|
|
|
|
async function handler(req: NextApiRequest) {
|
|
// Get user
|
|
await prisma.user.findFirstOrThrow({
|
|
where: {
|
|
id: req.session?.user?.id,
|
|
},
|
|
select: {
|
|
id: true,
|
|
},
|
|
});
|
|
|
|
const { client_id } = await getWebexAppKeys();
|
|
|
|
/** @link https://developer.webex.com/docs/integrations#requesting-permission */
|
|
const params = {
|
|
response_type: "code",
|
|
client_id,
|
|
redirect_uri: `${WEBAPP_URL}/api/integrations/${config.slug}/callback`,
|
|
scope: "spark:kms meeting:schedules_read meeting:schedules_write", //should be "A space-separated list of scopes being requested by your integration"
|
|
state: "",
|
|
};
|
|
const query = stringify(params).replaceAll("+", "%20");
|
|
const url = `https://webexapis.com/v1/authorize?${query}`;
|
|
return { url };
|
|
}
|
|
|
|
export default defaultHandler({
|
|
GET: Promise.resolve({ default: defaultResponder(handler) }),
|
|
});
|