0

List Teams

by
Published today

List the teams the connected user is a member of. Requires Team.ReadBasic.All (a connection default).

Script ms_teams Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 1 hour ago
1
//native
2

3
/**
4
 * List Teams
5
 * List the teams the connected user is a member of. Requires Team.ReadBasic.All (a connection default).
6
 */
7
export async function main(auth: RT.MsTeams) {
8
  const url = new URL(`https://graph.microsoft.com/v1.0/me/joinedTeams`)
9

10
  const response = await fetch(url, {
11
    headers: {
12
      Authorization: `Bearer ${auth.token}`,
13
      Accept: "application/json",
14
    },
15
  })
16

17
  if (!response.ok) {
18
    throw new Error(`${response.status} ${await response.text()}`)
19
  }
20

21
  return await response.json()
22
}
23