G suite user sync with Appsheet

adithya98
Participant I

Hi team,

I want a feature where we can integrate g suite domain so that i can able to fetch all the users and admins and it should be in sync with the g suite account.

The main reason for this feature is I can able to restrict the certain views for normal users and can give full access to all views to admins in the g suite.

It would be greate if any other ways to achieve it instead of adding manually in the sheets everytime

Solved Solved
0 4 454
1 ACCEPTED SOLUTION

JTL
Observer

@adithya98 Sounds like you need to enable the advanced service under Resources -> Advanced Google Services -> Slide the service for AdminDirectory to on and hit ok.

View solution in original post

4 REPLIES 4

I think this is a great feature request!

As an automated workaround, you may be able to create a Google script which can retrieve the G-Suite users and insert them into your AppSheet app users table. I donโ€™t know of an automated way to add users to the appโ€™s user whitelist (anyone else?) so that may still need to be performed manually but you could have the script send an email when a new user needs to be added.

Thanks @WillowMobileSystems I am trying this Google Script which is attached to the spreadsheet of my Appsheet app ``` function myFunction() {

var sh = โ€˜11KKjcV-ixYt6EWhs_k6Jb2ctMJeXWH3uSX4W4sHqniUโ€™; //This line will specify which Spreadsheet to Open//
var sheet = SpreadsheetApp.openById(sh);
var sheet1 = sheet.getSheetByName(โ€˜Google Usersโ€™);

var sheet1range = sheet.getRange(โ€œA:Fโ€)
sheet1range.clear()

var data = ;// array to store values
data.push([โ€˜Emailโ€™ ,โ€˜Firstnameโ€™, โ€˜Lastnameโ€™, โ€˜Suspendedโ€™, โ€˜LastLoginTimeโ€™,โ€˜Creationโ€™]);// store headers
var pageToken, page;
do {
page = AdminDirectory.Users.list({

  domain: 'domainname',
 
  pageToken: pageToken
});
var users = page.users;
if (users) {
  for (var i = 0; i < users.length; i++) {
    
    var user = users[i];
    
    
    data.push([user.primaryEmail, user.name.givenName, user.name.familyName, user.suspended, user.lastLoginTime , user.creationTime  ]);//store in an array of arrays (one for each row)
  }
} else {
Logger.log('No users found.');
   }
pageToken = page.nextPageToken;

} while (pageToken);

sheet1.getRange(1,1,data.length,data[0].length).setValues(data);
var dated = sheet.getRange(โ€œP1โ€)

dated.setValue(Utilities.formatDate(new Date(),Session.getScriptTimeZone(),โ€˜dd-MMM-yyyโ€™));
} ```

but it shows error ReferenceError: AdminDirectory is not defined someone please help

JTL
Observer

@adithya98 Sounds like you need to enable the advanced service under Resources -> Advanced Google Services -> Slide the service for AdminDirectory to on and hit ok.

Thanks @JTL Its working!!

Top Labels in this Space