บริการเครื่องมือจัดการใบอนุญาตของ Admin SDK Enterprise

ใน Apps Script เพื่อมอบหมาย อัปเดต เรียกข้อมูล และลบใบอนุญาตผู้ใช้

บริการ Enterprise License Manager ของ Admin SDK ช่วยให้คุณใช้ Admin SDK Enterprise License Manager API ใน Google Apps Script ได้ API นี้ช่วยให้ผู้ดูแลระบบโดเมนสามารถมอบหมาย อัปเดต เรียกข้อมูล และลบใบอนุญาตของผู้ใช้ได้

นี่เป็นบริการขั้นสูงที่ต้องเปิดใช้ก่อนใช้งาน

ข้อมูลอ้างอิง

ดูข้อมูลโดยละเอียดเกี่ยวกับบริการนี้ได้ในเอกสารอ้างอิงสำหรับ Admin SDK Enterprise License Manager API เช่นเดียวกับบริการขั้นสูงทั้งหมดใน Apps Script บริการ Enterprise License Manager ของ Admin SDK จะใช้ออบเจ็กต์ เมธอด และพารามิเตอร์เดียวกันกับ API สาธารณะ ดูข้อมูลเพิ่มเติมได้ที่วิธีกำหนดลายเซ็นของเมธอด

หากต้องการรายงานปัญหาและรับการสนับสนุนอื่นๆ โปรดดูคู่มือการสนับสนุน Admin SDK Enterprise License Manager

โค้ดตัวอย่าง

โค้ดตัวอย่างต่อไปนี้ใช้ API เวอร์ชัน 1

รับรายการการมอบหมายใบอนุญาตสำหรับโดเมน

ตัวอย่างนี้จะบันทึกการมอบหมายใบอนุญาต รวมถึงรหัสสินค้าและรหัส SKU สำหรับผู้ใช้ในโดเมน โปรดสังเกตการใช้โทเค็นหน้าเว็บเพื่อเข้าถึงรายการผลลัพธ์ทั้งหมด

advanced/adminSDK.gs
/**
 * Logs the license assignments, including the product ID and the sku ID, for
 * the users in the domain. Notice the use of page tokens to access the full
 * list of results.
 */
function getLicenseAssignments() {
  const productId = "Google-Apps";
  const customerId = "example.com";
  let assignments = [];
  let pageToken = null;
  do {
    const response = AdminLicenseManager.LicenseAssignments.listForProduct(
      productId,
      customerId,
      {
        maxResults: 500,
        pageToken: pageToken,
      },
    );
    assignments = assignments.concat(response.items);
    pageToken = response.nextPageToken;
  } while (pageToken);
  // Print the productId and skuId
  for (const assignment of assignments) {
    console.log(
      "userId: %s, productId: %s, skuId: %s",
      assignment.userId,
      assignment.productId,
      assignment.skuId,
    );
  }
}

แทรกการมอบหมายใบอนุญาตสำหรับผู้ใช้

ตัวอย่างนี้แสดงวิธีแทรกการมอบหมายใบอนุญาตสำหรับผู้ใช้สำหรับชุดค่าผสมรหัสสินค้าและรหัส SKU ที่ระบุ

advanced/adminSDK.gs
/**
 * Insert a license assignment for a user, for a given product ID and sku ID
 * combination.
 * For more details follow the link
 * https://developers.google.com/admin-sdk/licensing/reference/rest/v1/licenseAssignments/insert
 */
function insertLicenseAssignment() {
  const productId = "Google-Apps";
  const skuId = "Google-Vault";
  const userId = "marty@hoverboard.net";
  try {
    const results = AdminLicenseManager.LicenseAssignments.insert(
      { userId: userId },
      productId,
      skuId,
    );
    console.log(results);
  } catch (e) {
    // TODO (developer) - Handle exception.
    console.log("Failed with an error %s ", e.message);
  }
}