How to get user email of a Google spreadsheet Add-On?

前端 未结 1 382
旧时难觅i
旧时难觅i 2021-01-15 00:40

I created an add-on for Google spreadsheets.

Everytime it runs, it must check the user\'s email address

Session.getActiveUser().getEmail();
         


        
1条回答
  •  清酒与你
    2021-01-15 01:31

    Essentially, it's intended that this is nearly impossible, or at least incredibly difficult. As the documentation you linked indicates, you're not able to pull another users email address using a custom function in sheets, and this is a good thing, as it would be easy to farm email addresses using this method on unsuspecting users.

    A great rule of thumb is -> If they're not using Google Apps in the same organisation as yourself = You can't get their email address. (A moments thought shows us why this is a good thing. Once you authorise someone to see what your address is, even for a legitimate purpose, you have no idea what they do with it after, and spammers and scammers would love to be able to use Apps script to farm addresses).

    The only reasonable solution here is to have the script check for the address, and if a blank string is returned, request the user manually enter their address into a text box into the form/sheet/App etc.

    0 讨论(0)
提交回复
热议问题