0

I want to build a WebApp in Google AppsScript that can pull information for the user accessing it. I want to pull their ChromeOS version (if they use a Chromebook) and their Chrome browser version.

I have searched the Google APIs but haven't seen anything that could do this efficiently/adequately. I could use Session.getActiveUser().getEmail() to get the person accessing the script and then do something like:

  const response = AdminDirectory.Chromeosdevices.list(customer).chromeosdevices.forEach(device => {
    if (device.recentUsers != null)
    deviceArr.push([device.deviceId, device.recentUsers[0].email])
    } 

Pushing the 'recent' user for each device into an array, and then do something like:

  deviceArr.forEach(usrDev => {
    const user = usrDev[2]
    const devInf = AdminDirectory.Chromeosdevices.get(customer,usrDev[0]).osVersion
    console.log("USER: "+user+" || ChromeOS Version: "+devInf)
  })

And then do a lookup against the active user... but that seems hella clunky for something that feels like it should be pretty straightforward.

Can someone help me or point me in the right direction here?

Rubén
  • 34,714
  • 9
  • 70
  • 166
SL8t7
  • 617
  • 2
  • 9
  • 27
  • To interact with the browser, you have to get "off" of the Google servers where Apps Script is running and into a browser window where you can use regular Javascript. So you will have to develop a webapp with an html interface, and a "doGet()" function to serve the file. You could then add Javascript to do whatever is normally allowed in the browser, and then send the information back to your Apps Script using "google.script.run" or other method to push data to the backend. ~good luck! – Clark Lind Nov 23 '22 at 14:55
  • You could also do it with a dialog thus avoiding the need for messing around with the doGet or doPost altogether. You can still use google.script.run to return the information to the server and then close the dialog with google.script.host.close() – Cooper Nov 23 '22 at 18:56

0 Answers0