title: Give permission in a gmail addon
body: <p>I'm trying to put together a script for Gmail in Google Apps Scripts add-on that will reply to all email on weekends with an out of office message:</p>
  <pre><code>function autoReply() {
    var interval = 5;        //  if the script runs every 5 minutes; change otherwise
    var daysOff = [5];   // 1=Mo, 2=Tu, 3=We, 4=Th, 5=Fr, 6=Sa, 0=Su
    var date = new Date();
    var day = date.getDay();
    var label = GmailApp.getUserLabelByName(&quot;autoresponded&quot;);
    if (daysOff.indexOf(day) &gt; -1) {
      var timeFrom = Math.floor(date.valueOf()/1000) - 60 * interval;
      var threads = GmailApp.search('is:inbox !label:autoresponded after:' + timeFrom);
      for (var i = 0; i &lt; threads.length; i++) {
        var message = threads[i].getMessages()[0];
        if (message.getFrom().indexOf(&quot;myemail@gmail.com&quot;) &lt; 0 &amp;&amp; message.getFrom().indexOf(&quot;no-repl&quot;) &lt; 0 &amp;&amp; message.getFrom().indexOf(&quot;bounce&quot;) &lt; 0 &amp;&amp; message.getFrom().indexOf(&quot;spam&quot;) &lt; 0) {
          threads[i].reply(&quot;&quot;, {
            htmlBody: &quot;&lt;p&gt;Thank you for your message. We will get back to you as soon as possible. &lt;/p&gt;&quot;
          });
          label.addToThread(threads[i]);
        }
      }
    }
  }
  </code></pre>
  <p>I keep getting this error however:</p>
  <blockquote>
  <p>Exception: The script does not have permission to perform that action. Required permissions: <code>(https://www.googleapis.com/auth/gmail.labels || https://www.googleapis.com/auth/gmail.metadata || https://www.googleapis.com/auth/gmail.readonly || https://www.googleapis.com/auth/gmail.modify || https://mail.google.com/)</code></p>
  </blockquote>
  <p>This happened after I allowed permission in Gmail for my Gmail account. Is there something I'm missing here? Another layer that this is going through?</p>
  <p>I tried deleting the add-on and re-allowing permissions for Gmail but no luck. The trigger for the add-on is every 5 mins just like the interval in the script.
  I tried going to the links in the errors but they just came up with blank pages.</p>