title: how to use pagetoken google app script
body: <p>I am using Google Apps Script to write a list of all super admins and delegated admins in our google apps istance.</p>
  
  <p>my script works fine, but it limits the result to 500 users as thats the limit google has, and google suggests to use pageToken for it, however am not sure how to it use.</p>
  
  <p>Can anyone help me understand how do i use PageToken in following script-:</p>
  
  <pre><code>function getAdmins(){
  var fileArray = [["First Name", "Last Name", "Email", "Admin Role"]]
  
    var optionalArgs = {"customer":"my_customer", maxResults: 500}  
    var allUsers = AdminDirectory.Users.list(optionalArgs).users
  
    for (i=0; i&lt;allUsers.length; i++){
    userDetails = allUsers[i]
    var fName = userDetails.name.givenName
    var lName = userDetails.name.familyName
    var pEmail = userDetails.primaryEmail
    var Admin = userDetails.isAdmin
    var dAdmin = userDetails.isDelegatedAdmin
  
    if (Admin === true) {
      Admin = "Super Administrator"
    }
      else if (dAdmin === true){
        Admin = "Delegated Administrator"
     }
      Logger.log(Admin)
  
      }
    var ss = SpreadsheetApp.getActive()
    var sheet = ss.getSheetByName("Admin Users")
    fileArray.push([fName, lName, pEmail,Admin]);
  
    Logger.log(fileArray) 
  
  
  
    sheet.getRange(1, 1, fileArray.length, 4).setValues(fileArray)
  
  
    }}
  </code></pre>