type Github = {
token: string;
};
/**
* Create an installation access token for an app
* Creates an installation access token that enables a GitHub App to make authenticated API requests for the app's installation on an organization or individual account.
*/
export async function main(
auth: Github,
installation_id: string,
body: {
permissions?: {
actions?: "read" | "write";
administration?: "read" | "write";
checks?: "read" | "write";
contents?: "read" | "write";
deployments?: "read" | "write";
environments?: "read" | "write";
issues?: "read" | "write";
members?: "read" | "write";
metadata?: "read" | "write";
organization_administration?: "read" | "write";
organization_announcement_banners?: "read" | "write";
organization_custom_roles?: "read" | "write";
organization_hooks?: "read" | "write";
organization_packages?: "read" | "write";
organization_plan?: "read";
organization_projects?: "read" | "write" | "admin";
organization_secrets?: "read" | "write";
organization_self_hosted_runners?: "read" | "write";
organization_user_blocking?: "read" | "write";
packages?: "read" | "write";
pages?: "read" | "write";
pull_requests?: "read" | "write";
repository_announcement_banners?: "read" | "write";
repository_hooks?: "read" | "write";
repository_projects?: "read" | "write" | "admin";
secret_scanning_alerts?: "read" | "write";
secrets?: "read" | "write";
security_events?: "read" | "write";
single_file?: "read" | "write";
statuses?: "read" | "write";
team_discussions?: "read" | "write";
vulnerability_alerts?: "read" | "write";
workflows?: "write";
[k: string]: unknown;
};
repositories?: string[];
repository_ids?: number[];
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.github.com/app/installations/${installation_id}/access_tokens`
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 271 days ago
type Github = {
token: string;
};
/**
* Create an installation access token for an app
* Creates an installation access token that enables a GitHub App to make authenticated API requests for the app's installation on an organization or individual account.
*/
export async function main(
auth: Github,
installation_id: string,
body: {
permissions?: {
actions?: "read" | "write";
administration?: "read" | "write";
checks?: "read" | "write";
contents?: "read" | "write";
deployments?: "read" | "write";
environments?: "read" | "write";
issues?: "read" | "write";
members?: "read" | "write";
metadata?: "read" | "write";
organization_administration?: "read" | "write";
organization_announcement_banners?: "read" | "write";
organization_custom_roles?: "read" | "write";
organization_hooks?: "read" | "write";
organization_packages?: "read" | "write";
organization_plan?: "read";
organization_projects?: "read" | "write" | "admin";
organization_secrets?: "read" | "write";
organization_self_hosted_runners?: "read" | "write";
organization_user_blocking?: "read" | "write";
packages?: "read" | "write";
pages?: "read" | "write";
pull_requests?: "read" | "write";
repository_announcement_banners?: "read" | "write";
repository_hooks?: "read" | "write";
repository_projects?: "read" | "write" | "admin";
secret_scanning_alerts?: "read" | "write";
secrets?: "read" | "write";
security_events?: "read" | "write";
single_file?: "read" | "write";
statuses?: "read" | "write";
team_discussions?: "read" | "write";
vulnerability_alerts?: "read" | "write";
workflows?: "write";
[k: string]: unknown;
};
repositories?: string[];
repository_ids?: number[];
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.github.com/app/installations/${installation_id}/access_auth.tokens`
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 276 days ago