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

บริการ Admin SDK Enterprise License Manager อนุญาตให้คุณใช้ Admin SDK Enterprise License Manager API ใน 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);
  }
}