Set the customization template for an OIDC subject claim for an organization

Creates or updates the customization template for an OpenID Connect (OIDC) subject claim. You must authenticate using an access token with the `write:org` scope to use this endpoint. GitHub Apps must have the `admin:org` permission to use this endpoint.

Script github Verified

by hugo697 ยท 10/25/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 366 days ago
1
type Github = {
2
  token: string;
3
};
4
/**
5
 * Set the customization template for an OIDC subject claim for an organization
6
 * Creates or updates the customization template for an OpenID Connect (OIDC) subject claim.
7
You must authenticate using an access token with the `write:org` scope to use this endpoint.
8
GitHub Apps must have the `admin:org` permission to use this endpoint.
9
 */
10
export async function main(
11
  auth: Github,
12
  org: string,
13
  body: { include_claim_keys: string[]; [k: string]: unknown }
14
) {
15
  const url = new URL(
16
    `https://api.github.com/orgs/${org}/actions/oidc/customization/sub`
17
  );
18

19
  const response = await fetch(url, {
20
    method: "PUT",
21
    headers: {
22
      "Content-Type": "application/json",
23
      Authorization: "Bearer " + auth.token,
24
    },
25
    body: JSON.stringify(body),
26
  });
27
  if (!response.ok) {
28
    const text = await response.text();
29
    throw new Error(`${response.status} ${text}`);
30
  }
31
  return await response.json();
32
}
33