CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/pages/api/v2/api-key.ts
Views: 687
1
/*
2
v2 API endpoint for managing your legacy API key.
3
*/
4
5
import getAccountId from "lib/account/get-account";
6
import { legacyManageApiKey } from "@cocalc/server/api/manage";
7
import getParams from "lib/api/get-params";
8
9
export default async function handle(req, res) {
10
try {
11
const account_id = await getAccountId(req);
12
if (!account_id) {
13
throw Error("must be signed in");
14
}
15
const { action, password } = getParams(req);
16
const api_key = await legacyManageApiKey({ account_id, password, action });
17
res.json({ api_key });
18
} catch (err) {
19
res.json({ error: err.message });
20
}
21
}
22
23