fix: Installing Zoho CRM (#11161)

* Fix installing Zoho CRM

* Clean up
pull/11171/head
Joe Au-Yeung 2023-09-06 01:08:59 -04:00 committed by GitHub
parent d06e36a5cd
commit 868ba4396d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 2 deletions

View File

@ -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 });
}