
* Initial changes * OAuth done and credentials stored * Added "other" integrations * Switching to hubspot api client * Event creation for all attendees * Update and delete done * Doc update * Fixing types * App label is not mandatory * Fixing bad merge: App label deleted * Fixing bad automerge * Removing c.log Co-authored-by: Omar López <zomars@me.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
22 lines
781 B
TypeScript
22 lines
781 B
TypeScript
import * as hubspot from "@hubspot/api-client";
|
|
import type { NextApiRequest, NextApiResponse } from "next";
|
|
|
|
import { WEBAPP_URL } from "@calcom/lib/constants";
|
|
|
|
const scopes = ["crm.objects.contacts.read", "crm.objects.contacts.write"];
|
|
|
|
const client_id = process.env.HUBSPOT_CLIENT_ID;
|
|
const hubspotClient = new hubspot.Client();
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
if (!client_id) {
|
|
res.status(400).json({ message: "HubSpot client id missing." });
|
|
return;
|
|
}
|
|
|
|
if (req.method === "GET") {
|
|
const redirectUri = WEBAPP_URL + "/api/integrations/hubspotothercalendar/callback";
|
|
const url = hubspotClient.oauth.getAuthorizationUrl(client_id, redirectUri, scopes.join(" "));
|
|
res.status(200).json({ url });
|
|
}
|
|
}
|