MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / action

Function action

apps/webapp/app/routes/api.v1.authorization-code.ts:9–40  ·  view source on GitHub ↗
({ request }: ActionFunctionArgs)

Source from the content-addressed store, hash-verified

7
8/** Used to create an AuthorizationCode, that can then be used to obtain a Personal Access Token by logging in with the provided URL */
9export async function action({ request }: ActionFunctionArgs) {
10 logger.info("Creating AuthorizationCode", { url: request.url });
11
12 // Ensure this is a POST request
13 if (request.method.toUpperCase() !== "POST") {
14 return { status: 405, body: "Method Not Allowed" };
15 }
16
17 //there is no authentication on this endpoint, anyone can create an AuthorizationCode.
18 //they're only used to allow a user to login, when they'll then receive a Personal Access Token
19
20 try {
21 const authorizationCode = await createAuthorizationCode();
22 const responseJson: CreateAuthorizationCodeResponse = {
23 authorizationCode: authorizationCode.code,
24 url: `${env.APP_ORIGIN}/account/authorization-code/${authorizationCode.code}`,
25 };
26
27 return json(responseJson);
28 } catch (error) {
29 if (error instanceof Error) {
30 logger.error("Error creating AuthorizationCode", {
31 url: request.url,
32 error: error.message,
33 });
34
35 return json({ error: error.message }, { status: 400 });
36 }
37
38 return json({ error: "Something went wrong" }, { status: 500 });
39 }
40}

Callers

nothing calls this directly

Calls 4

createAuthorizationCodeFunction · 0.90
jsonFunction · 0.85
infoMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…