Admin SDK Enterprise License Manager Service

The Admin SDK Enterprise License Manager service allows you to use the Admin SDK Enterprise License Manager API in Apps Script. This API allows domain admins to assign, update, retrieve, and delete user licenses.

Reference

For detailed information on this service, see the reference documentation for the Admin SDK Enterprise License Manager API. Like all advanced services in Apps Script, the Admin SDK Enterprise License Manager service uses the same objects, methods, and parameters as the public API.

To report issues and find other support, see the Admin SDK Enterprise License Manager support guide.

Sample code

The sample code below uses version 1 of the API.

Get a list of license assignments for the domain

This sample 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.

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() {
  var productId = 'Google-Apps';
  var customerId = 'example.com';
  var assignments;
  var pageToken;
  do {
    assignments = AdminLicenseManager.LicenseAssignments
        .listForProduct(productId, customerId, {
      maxResults: 500,
      pageToken: pageToken,
    });
  } while (pageToken);
  for (var i = 0; i < assignments.items.length; i++) {
    var assignment = assignments.items[i];
    Logger.log('userId: %s, productId: %s, skuId: %s',
        assignment.userId, assignment.productId, assignment.skuId);
  }
}

Insert a license assignment for a user

This sample demonstrates how to insert a license assignment for a user, for a given product ID and sku ID combination.

advanced/adminSDK.gs
/**
 * Insert a license assignment for a user, for a given product ID and sku ID
 * combination.
 */
function insertLicenseAssignment() {
  var productId = 'Google-Apps';
  var skuId = 'Google-Vault';
  var userId = 'marty@hoverboard.net';
  var results = AdminLicenseManager.LicenseAssignments
      .insert({userId: userId}, productId, skuId);
  Logger.log(results);
}

发送以下问题的反馈:

此网页
Apps Script
Apps Script
需要帮助?请访问我们的支持页面