MCPcopy Create free account
hub / github.com/firebase/firebase-tools / getGithubTokensFromAuthorizationCode

Function getGithubTokensFromAuthorizationCode

src/auth.ts:385–407  ·  view source on GitHub ↗
(code: string, callbackUrl: string)

Source from the content-addressed store, hash-verified

383}
384
385async function getGithubTokensFromAuthorizationCode(code: string, callbackUrl: string) {
386 const client = new apiv2.Client({ urlPrefix: githubOrigin(), auth: false });
387 const data = {
388 client_id: githubClientId(),
389 client_secret: githubClientSecret(),
390 code,
391 redirect_uri: callbackUrl,
392 state: _nonce,
393 };
394 const form = new FormData();
395 for (const [k, v] of Object.entries(data)) {
396 form.append(k, v);
397 }
398 const headers = form.getHeaders();
399 headers.accept = "application/json";
400 const res = await client.request<any, GitHubAuthResponse>({
401 method: "POST",
402 path: "/login/oauth/access_token",
403 body: form,
404 headers,
405 });
406 return res.body.access_token;
407}
408
409function respondHtml(
410 req: http.IncomingMessage,

Callers

nothing calls this directly

Calls 3

githubOriginFunction · 0.90
githubClientIdFunction · 0.90
githubClientSecretFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…