Admin SDK License Manager Service

The Admin SDK License Manager service allows you to use the Admin SDK 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 License Manager API. Like all advanced services in Apps Script, the Admin SDK License Manager service uses the same objects, methods, and parameters as the public API.

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.

function getLicenseAssignments() {
  var productId = 'Google-Apps';
  var customerId = 'example.com';
  var assignments, 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.

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