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

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

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

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

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

หากต้องการรายงานปัญหาและดูการสนับสนุนอื่นๆ โปรดดู คู่มือการสนับสนุน 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);
  }
}