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

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

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

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

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

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

ตัวอย่างโค้ดด้านล่างใช้ 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);
  }
}