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

Function getAuthenticatedGithubClient

apps/functions/code-of-conduct/shared.ts:105–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

103
104/** Retrieves a Github client instance authenticated as the Angular Robot Github App. */
105export async function getAuthenticatedGithubClient(): Promise<Octokit> {
106 const GITHUB_APP_PEM = Buffer.from(
107 process.env['ANGULAR_ROBOT_APP_PRIVATE_KEY']!,
108 'base64',
109 ).toString('utf-8');
110
111 const applicationGithub = new Octokit({
112 authStrategy: createAppAuth,
113 auth: {appId: process.env['ANGULAR_ROBOT_APP_ID']!, privateKey: GITHUB_APP_PEM},
114 });
115 /** The specific installation id for the provided repository. */
116 const {id: installation_id} = (await applicationGithub.apps.getOrgInstallation({org: 'angular'}))
117 .data;
118 /** A temporary github access token. */
119 const {token} = (
120 await applicationGithub.rest.apps.createInstallationAccessToken({installation_id})
121 ).data;
122
123 return new Octokit({auth: token});
124}

Callers 4

unblockUser.tsFile · 0.85
blockUser.tsFile · 0.85
syncUsersFunction · 0.85

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected