0

Get Profile

by
Published 5 days ago

Get the connected account's email address and mailbox totals. Requires gmail.readonly, gmail.compose or gmail.modify on the connection.

Script gmail Verified

The script

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

3
/**
4
 * Get Profile
5
 * Get the connected account's email address, total message and thread counts, and current `historyId`. Requires gmail.readonly, gmail.compose or gmail.modify on the connection (gmail.send alone is not enough).
6
 */
7
export async function main(auth: RT.Gmail) {
8
  const response = await fetch(
9
    "https://gmail.googleapis.com/gmail/v1/users/me/profile",
10
    {
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