From 868ba4396db76559bd4b5e34a37181b5a502db76 Mon Sep 17 00:00:00 2001 From: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Date: Wed, 6 Sep 2023 01:08:59 -0400 Subject: [PATCH] fix: Installing Zoho CRM (#11161) * Fix installing Zoho CRM * Clean up --- packages/app-store/zohocrm/api/_getAdd.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/app-store/zohocrm/api/_getAdd.ts b/packages/app-store/zohocrm/api/_getAdd.ts index edcc318885..cef586ac04 100644 --- a/packages/app-store/zohocrm/api/_getAdd.ts +++ b/packages/app-store/zohocrm/api/_getAdd.ts @@ -1,4 +1,5 @@ import type { NextApiRequest, NextApiResponse } from "next"; +import { stringify } from "querystring"; import { WEBAPP_URL } from "@calcom/lib/constants"; @@ -13,7 +14,18 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) if (!client_id) return res.status(400).json({ message: "zohocrm client id missing." }); const state = encodeOAuthState(req); - const redirectUri = WEBAPP_URL + "/api/integrations/zohocrm/callback"; - const url = `https://accounts.zoho.com/oauth/v2/auth?scope=ZohoCRM.modules.ALL,ZohoCRM.users.READ,AaaServer.profile.READ&client_id=${client_id}&response_type=code&access_type=offline&redirect_uri=${redirectUri}&state=${state}`; + const params = { + client_id, + response_type: "code", + redirect_uri: WEBAPP_URL + "/api/integrations/zohocrm/callback", + scope: ["ZohoCRM.modules.ALL", "ZohoCRM.users.READ", "AaaServer.profile.READ"], + access_type: "offline", + state, + prompt: "consent", + }; + + const query = stringify(params); + const url = `https://accounts.zoho.com/oauth/v2/auth?${query}`; + res.status(200).json({ url }); }