Edits history of script submission #23328 for ' List Send-As Aliases (gmail)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List Send-As Aliases
     * List the addresses the account can send mail from: the primary address plus any send-as aliases, with their display name, signature and `verificationStatus` (only `accepted` aliases can be used as `from` in Send Email). Requires gmail.readonly, gmail.modify or gmail.settings.basic on the connection.
     */
    export async function main(auth: RT.Gmail) {
      const response = await fetch(
        "https://gmail.googleapis.com/gmail/v1/users/me/settings/sendAs",
        {
          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