title: Active VS Effective User for Google Sheets
body: <p>I'm writing a simple google app script application which performs some data manipulation depends of the user who requests the page.</p>
  
  <p>According to <a href="https://developers.google.com/apps-script/reference/base/session" rel="nofollow">google documentation</a> object Session has <b>getActiveUser()</b> and <b>getEffectiveUser()</b> which I currently use in order to determine the user.
  Have a look at the code:</p>
  
  <pre><code>var email = Session.getActiveUser().getEmail();
    switch (email){
      case 'test@gmail.com':
        /*Some code here*/
        return true;
      case 'test2@gmail.com':
        /*Some code here*/
        return true;
      default:
        return false;
    }
  </code></pre>
  
  <p>It looks like that it should work, unfortunately it doesn't work as expected (at least for me).</p>
  
  <p>The code above runs when onOpen trigger fires, and all permissions are set when the user attempts to run this code for the first time.</p>
  
  <p>So, I've decided to perform tracing and found out that <code>Session.getActiveUser().getEmail();</code> and <code>Session.getEffectiveUser().getEmail();</code> return wrong emails for the users.</p>
  
  <p>For the 1-st user (me) who created a script <code>Session.getActiveUser().getEmail();</code> returns correct email, but for all the others it returns my email as well.
  Ok, I've decided to replace <code>Session.getActiveUser().getEmail();</code> with <code>Session.getEffectiveUser().getEmail();</code> and BOOM - it works for others but doesn't work for me...</p>
  
  <p>How could it be? Any thoughts?</p>
  
  <ul>
  <li><em>I've noticed that when I run the code from the ScriptEditor, code works like a charm for all the users, but when It runs when onOpen fires it works unpredictable.</em></li>
  </ul>
  
  <blockquote>
    <p>This spreadsheet is shared with several persons.</p>
  </blockquote>
  
  <p>Any help is appreciated.</p>