title: Digest Authentication with Google Apps Scripts using UrlFetch
body: <p>I'm trying to access a URL that is protected by Digest Authentication, using UrlFetch of Google Apps Script.</p>
  
  <p>I managed to access a URL using Basic Authentication:</p>
  
  <pre><code> var options =
  {
    "method" : "get",
    "headers" : {
      "Authorization" : "Basic &lt;Base64 of user:password&gt;"  
    },
  };
  
  var response = UrlFetchApp.fetch("http://www.example.com/service/using/basic", options);
  </code></pre>
  
  <p>and I managed to access with OAuth based on the <a href="https://developers.google.com/apps-script/class_urlfetchapp" rel="nofollow">example</a> in the documentation.</p>
  
  <p>The problem now is that I need to have the same functionality with a site that is implementing Digest. I can access it with the following curl:</p>
  
  <pre><code>curl -v --digest --user user:password http://www.example.com/service/using/digest
  </code></pre>
  
  <p><strong>Updated</strong></p>
  
  <p>If I try to simply call</p>
  
  <pre><code>var options =
  {
    "method" : "get",
    "headers" : {
      "Authorization" : "Digest " + Utilities.base64Encode( Utilities.computeDigest(user:password) )
    },
  };
  </code></pre>
  
  <p>It doesn't work due to the Challenge-Response mechanism of Digest Authentication.</p>
  
  <p>Can I have it with UrlFetch using any JavaScript library that is implementing such functionality? or directly by UrlFetch itself? </p>