* WIP * warnings and errors, and working app * Refresh token now usable * Correcting env.appStore.example * Reverting changes that will come from Sendgrid App PR * Resetting with main * Renaming all othercalendars * Fixing types * Renaming leftovers * More renaming stuff * Format readme * Adds prettier override for website wordlist * Omit salesforce app in this PR * Revert "Omit salesforce app in this PR" This reverts commit 22c09fe53578fc37293027ef3667e1bdf2d6c6e7. * Update yarn.lock Co-authored-by: Leo Giovanetti <hello@leog.me> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
25 lines
938 B
TypeScript
25 lines
938 B
TypeScript
import jsforce from "jsforce";
|
|
import type { NextApiRequest, NextApiResponse } from "next";
|
|
|
|
import { WEBAPP_URL } from "@calcom/lib/constants";
|
|
|
|
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
|
|
|
|
let consumer_key = "";
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
if (req.method !== "GET") return res.status(405).json({ message: "Method not allowed" });
|
|
|
|
const appKeys = await getAppKeysFromSlug("salesforce");
|
|
if (typeof appKeys.consumer_key === "string") consumer_key = appKeys.consumer_key;
|
|
if (!consumer_key) return res.status(400).json({ message: "Salesforce client id missing." });
|
|
|
|
const salesforceClient = new jsforce.Connection({
|
|
clientId: consumer_key,
|
|
redirectUri: `${WEBAPP_URL}/api/integrations/salesforce/callback`,
|
|
});
|
|
|
|
const url = salesforceClient.oauth2.getAuthorizationUrl({ scope: "refresh_token full" });
|
|
res.status(200).json({ url });
|
|
}
|