(code: string, callbackUrl: string)
| 383 | } |
| 384 | |
| 385 | async 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 | |
| 409 | function respondHtml( |
| 410 | req: http.IncomingMessage, |
nothing calls this directly
no test coverage detected
searching dependent graphs…