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. For more information, see How method signatures are determined .

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 
 () 
  
 { 
  
 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 
 ); 
  
 } 
 } 

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. 
 * 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 
 ); 
  
 } 
 } 
Create a Mobile Website
View Site in Mobile | Classic
Share by: