0

Get Current User

by
Published today

Get the profile of the connected account (id, display name, mail, user principal name). Requires User.Read (a connection default).

Script ms_outlook Verified

The script

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

3
/**
4
 * Get Current User
5
 * Get the profile of the connected account (id, display name, mail, user principal name). Requires User.Read (a connection default).
6
 */
7
export async function main(auth: RT.MsOutlook) {
8
  const response = await fetch("https://graph.microsoft.com/v1.0/me", {
9
    headers: {
10
      Authorization: `Bearer ${auth.token}`,
11
      Accept: "application/json",
12
    },
13
  })
14

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

19
  return await response.json()
20
}
21