title: Send HTTP GET request with Basic authentication token
body: <p>I am trying to fetch information from a site with basic authentication (username and password), I followed documentation and some forums here, but I can't get it to work.</p>
  <p>Whenever I run the function, it returns the HTML from the login website, as if the authentication isn't working.</p>
  <pre><code>function getRequest() {
  
  var url = &quot;URL&quot;;
  var username = &quot;USER&quot;;
  var password = &quot;PASSWRD&quot;;
  
  var headers = {
      &quot;Authorization&quot; : &quot;Basic &quot; + Utilities.base64Encode(username + &quot;:&quot; + password)
  };
  
  var params = {
    &quot;method&quot;:&quot;GET&quot;,
    &quot;headers&quot;: headers
  };
      
  const response = UrlFetchApp.fetch(url, params);
  
  Logger.log(response.getContentText());
  
  }
  </code></pre>
  <p>I need it to return the contents from the website already logged in.</p>