0
Get the customization template for an OIDC subject claim for an organization
One script reply has been approved by the moderators Verified

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

Created by hugo697 407 days ago Viewed 9014 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 407 days ago
1
type Github = {
2
  token: string;
3
};
4
/**
5
 * Get the customization template for an OIDC subject claim for an organization
6
 * Gets the customization template for an OpenID Connect (OIDC) subject claim.
7
You must authenticate using an access token with the `read:org` scope to use this endpoint.
8
GitHub Apps must have the `organization_administration:write` permission to use this endpoint.
9
 */
10
export async function main(auth: Github, org: string) {
11
  const url = new URL(
12
    `https://api.github.com/orgs/${org}/actions/oidc/customization/sub`
13
  );
14

15
  const response = await fetch(url, {
16
    method: "GET",
17
    headers: {
18
      Authorization: "Bearer " + auth.token,
19
    },
20
    body: undefined,
21
  });
22
  if (!response.ok) {
23
    const text = await response.text();
24
    throw new Error(`${response.status} ${text}`);
25
  }
26
  return await response.json();
27
}
28