G suite user sync with Appsheet

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 560
1 ACCEPTED SOLUTION

JTL
New Member

@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
New Member

@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