Edits history of script submission #23327 for ' List Labels (gmail)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List Labels
     * List the mailbox's system labels (INBOX, UNREAD, ...) and user labels with their ids. Requires gmail.labels, gmail.readonly or gmail.modify on the connection.
     */
    export async function main(auth: RT.Gmail) {
      const response = await fetch(
        "https://gmail.googleapis.com/gmail/v1/users/me/labels",
        {
          headers: {
            Authorization: `Bearer ${auth.token}`,
            Accept: "application/json",
          },
        }
      )
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 6 hours ago