0

List OAuth applications

by
Published Oct 17, 2025

### Authorization A service token must have at least one of the following access in order to use this API endpoint: **Service Token Accesses** `read_oauth_applications`

Script planetscale Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Planetscale = {
3
  serviceTokenId: string;
4
  serviceToken: string;
5
};
6
/**
7
 * List OAuth applications
8
 * 
9
### Authorization
10
A service token   must have at least one of the following access   in order to use this API endpoint:
11

12
**Service Token Accesses**
13
 `read_oauth_applications`
14

15

16
 */
17
export async function main(
18
  auth: Planetscale,
19
  organization: string,
20
  page: string | undefined,
21
  per_page: string | undefined,
22
) {
23
  const url = new URL(
24
    `https://api.planetscale.com/v1/organizations/${organization}/oauth-applications`,
25
  );
26
  for (const [k, v] of [
27
    ["page", page],
28
    ["per_page", per_page],
29
  ]) {
30
    if (v !== undefined && v !== "" && k !== undefined) {
31
      url.searchParams.append(k, v);
32
    }
33
  }
34
  const response = await fetch(url, {
35
    method: "GET",
36
    headers: {
37
      Authorization: `${auth.serviceTokenId}:${auth.serviceToken}`,
38
    },
39
    body: undefined,
40
  });
41
  if (!response.ok) {
42
    const text = await response.text();
43
    throw new Error(`${response.status} ${text}`);
44
  }
45
  return await response.json();
46
}
47