Friday 15 June 2012

google script Session.getActiveUser().getEmail() not working -


I have developed a web app with Google Script and this is the code in my GS.

  Var email = session. Gate active user () GetEmail (); Logger.log (email); // Then do something to render an email address on the page   

After publishing the script, I log in to another account and execute the script.

Then display the page:

This application was created by another user, not by Google.

This application has access to the following personal information: Email

but nothing in the log and the page shows nothing .

I do not get it ...

However in the reference document for the session Not explicitly told. GetActiveUser (), my test has confirmed that accessing your web app to access the user requires access to GetActiveUser () I used the code below in the web app and

Depending on the case of your application, you may have been able to capture the active user email. Then, create another project that works with your personal spreadsheet and the same script DB library. LOG_FILENAME = 'your-log-doc' var LOG_PATH = 'folder / subfolder / third folder' function DoGet () {// a good path for you and change variable above the filename Var x = LogLibrary.InitializeLogging (LOG_PATH, LOG_FILENAME) Logger.log (x) var email = session .getActiveUser (). GetEmail (); Logger.log ("Start Email Logging") Logger.log (email); LogLibrary.fnSaveLog () // Write and flush the logger content / then to do some HTML address on page var, some HTMLToOutput = '& lt; Html & gt; & Lt; H1 & gt; A header & lt; / H1> & Lt; P & gt; '+ Email +' & lt; / P & gt; & Lt; / Html & gt; '; Return HtmlService.createHtmlOutput (HTMLToOutput); }

No comments:

Post a Comment