authentication - Google script: cannot refer to users using Session.getActiveUser() -


i have google script executes me. in script, want know user's email. refer email of user accessing application session.getactiveuser().getemail()

that's not working out @ all. google script giving error, saying session.getactiveuser().getemail() null.

when manually enter dummy email instead of session.getactiveuser().getemail(), code works perfectly

heeeeelp

ps: app must execute me, because needs access contacts.

you cannot have session.getactiveuser().getemail() return user's email id while app running you. there workarounds can try

  1. ask user's email id explicitly.

  2. write 2 scripts - 1 front end ui etc. run user accessing app (this allows session.getactiveuser().getemail() return user's email address). have second script tasks contacts accessed. call second script first using dopost , doget methods in second script. example,

script 1:

function whatever(){   urlfetchapp.fetch('service_url_of_script_2');  } 

script 2:

function doget(e){   // code access contact, parameters in e.parameters  } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -