MCPcopy Create free account
hub / github.com/angular/dev-infra / getAuthTokenFor

Function getAuthTokenFor

github-actions/utils.ts:39–61  ·  view source on GitHub ↗
(
  app: GithubAppMetadata,
  orgOrRepo: Org | Repo = context.repo,
)

Source from the content-addressed store, hash-verified

37export async function getAuthTokenFor(app: GithubAppMetadata, org: Org): Promise<string>;
38export async function getAuthTokenFor(app: GithubAppMetadata, repo?: Repo): Promise<string>;
39export async function getAuthTokenFor(
40 app: GithubAppMetadata,
41 orgOrRepo: Org | Repo = context.repo,
42): Promise<string> {
43 const github = await getJwtAuthedAppClient(app);
44 let id: number;
45 let org = orgOrRepo as Org;
46 let repo = orgOrRepo as Repo;
47
48 if (typeof org.org === 'string') {
49 id = (await github.apps.getOrgInstallation({...org})).data.id;
50 } else {
51 id = (await github.apps.getRepoInstallation({...repo})).data.id;
52 }
53
54 const {token} = (
55 await github.rest.apps.createInstallationAccessToken({
56 installation_id: id,
57 })
58 ).data;
59
60 return token;
61}
62
63/** Revoke the currently-authenticated installation token for the Octokit instance. */
64export async function revokeActiveInstallationToken(octokitInstallation: Octokit): Promise<void>;

Callers 8

mainFunction · 0.85
mainFunction · 0.85
runFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
githubFunction · 0.85

Calls 1

getJwtAuthedAppClientFunction · 0.85

Tested by

no test coverage detected