Home > database >  how to store the email of the google app script installing users
how to store the email of the google app script installing users

Time:12-08

I have google sheets addon in Google Workspace Marketplace. I want to store the emails of the users installing the addon. I'm thinking of three possible ways.

  1. Write to private spreadsheet under the addon account (different than the user's). Addon is running under user's so the question is, is this even possible - accessing the addon account (specifically writing to a spreadsheet) from within the user google account context?

  2. using PropertiesService - Write the user to script properties using PropertiesService class. One problem with this one is the limitations as explained in Quotas for Google Services. for me, at lease for now, this is enough. However the question is how to access those script properties programmatically. Of course I can access the data from the script editor, but this is not practical if I want for example to send mail to all the users.

  3. adding code to the addon that will be available only for specific users (admin). In this case since I can read the users from the script properties, and maybe write them to spreadsheet to be used later. This looks ugly, I admit.

I'm not asking for code solutions, but suggestions for the right or best approach.

CodePudding user response:

The easiest solution is to create a database

  • Create a spreadsheet located on your Drive, shared as "Everyne can edit".
  • Implement a flow where after Add-n installation data containing the user"s email will be appended to the spreadsheet.
  • This request will take place on user's beahlf, however given that the spreadsheet is shared publicly, there won't be any access permission issues
  • Even if the spreadsheet is shred publicly - given that the spreadsheet id is not known by anyone other than the Add-on code, you do not need to worry about undesired access to the database.
  • Related