Google Apps Script Web App authenticate on external website
<p>I need to implement a Google Apps Script app that is used to login on a website and then if the authentication process succeed on that website the user should receive a message in the google script sidebar.</p>
<p>For example: the user enters his email and password and then he press the Login button, then he should be logged in on the website if the credentials are correct.</p>
<p>Let me know if I need to provide more details on this... I am new with Google Apps Script and I really need some help with this login process. Thank you!</p>
<p>I tried to implement the following code but I receive the following error message when executing the <code>login</code> function:</p>
<blockquote>
<p>Request failed for <a href="https://example.com/login" rel="nofollow noreferrer">https://example.com/login</a> returned code 405.</p>
</blockquote>
<p>HTML file:</p>
<pre><code>&lt;div class=&quot;form-auth&quot;&gt;
  &lt;label class=&quot;inline&quot;&gt;username&lt;/label&gt;
  &lt;input type=&quot;text&quot; placeholder=&quot;Insert Email&quot;/&gt;
&lt;/div&gt;
&lt;div class=&quot;form-auth&quot;&gt;
  &lt;label class=&quot;inline&quot;&gt;password&lt;/label&gt;
  &lt;input placeholder=&quot;Insert Password&quot;/&gt;
&lt;/div&gt;
&lt;button class=&quot;btn-default&quot;&gt;Login&lt;/button&gt;
</code></pre>
<p>Google Script file:</p>
<pre><code>function onOpen() {
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('Menu')
      .addItem('Show sidebar', 'showSidebar')
      .addToUi();
}

function showSidebar() {
  var html = HtmlService.createHtmlOutputFromFile('login')
      .setSandboxMode(HtmlService.SandboxMode.IFRAME)
      .setTitle('SDR Tag Governance')
      .setWidth(300);
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .showSidebar(html);
}

function login() {
  var payload =
   {
     &quot;username&quot; : &quot;myEmail@domain.com&quot;,
     &quot;password&quot; : &quot;myPassword&quot;,
   };
  var options =
   {
     &quot;method&quot; : &quot;post&quot;,
     &quot;payload&quot; : payload,
     &quot;followRedirects&quot; : false
   };
  var login = UrlFetchApp.fetch(&quot;https://example.com/login&quot; , options);
  var sessionDetails = login.getAllHeaders()['Set-Cookie'];
}
</code></pre>