title: Authenticate or Bypass Login Downloading Google Drive File
body: <p>I am trying to download a large file from my Google Drive, using the requests module solution <a href="https://stackoverflow.com/questions/25010369/wget-curl-large-file-from-google-drive/39225039#39225039">here</a>. (It's the solution with 151 points.)</p>
  
  <p>The problem I run into is that the file is not downloaded, only the response from what I think are several redirects. I end up with a 1500 line file that looks like this: </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
    &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;meta content="width=300, initial-scale=1" name="viewport"&gt;
    &lt;meta name="description" content="Google Drive is a free way to keep your files backed up and easy to reach from any phone, tablet, or computer. Start with 15GB of Google storage – free."&gt;
    &lt;meta name="google-site-verification" content="LrdTUW9psUAMbh4Ia074-BPEVmcpBxF6Gwf0MSgQXZs"&gt;
    &lt;title&gt;Meet Google Drive – One place for all your files&lt;/title&gt;
    &lt;style&gt;
    @font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 300;
    src: local('Open Sans Light'), local('OpenSans-Light'), url(//fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN_r8OUuhs.ttf) format('truetype');
  }
  @font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 400;
    src: local('Open Sans'), local('OpenSans'), url(//fonts.gstatic.com/s/opensans/v15/mem8YaGs126MiZpBA-UFVZ0e.ttf) format('truetype');
  }
    &lt;/style&gt;
    &lt;style&gt;
    h1, h2 {
  </code></pre>
  
  <p>...</p>
  
  <pre><code>  } catch (err) {
    document.getElementById('bgresponse').value = '';
    }
    return true;
    }
    document.getElementById('gaia_loginform').onsubmit = gaia_onLoginSubmit;
    var signinButton;
    signinButton = document.getElementById('next');
    gaia_attachEvent(window, 'load', function(){
    gaia_scrollToElement(signinButton);
    });
    })();
  &lt;/script&gt;
    &lt;script nonce="0B6waBnPr4W7otWlyB0B/g"&gt;var e=this,g=function(a,c){a=a.split(".");var b=e;a[0]in b||!b.execScript||b.execScript("var "+a[0]);for(var d;a.length&amp;&amp;(d=a.shift());)a.length||void 0===c?b[d]?b=b[d]:b=b[d]={}:b[d]=c};var h=function(){try{return new XMLHttpRequest}catch(b){for(var a=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],c=0;c&lt;a.length;c++)try{return new ActiveXObject(a[c])}catch(d){}}return null};g("gaia.ajax.newXmlHttpRequest",h);var k=function(){this.a=h();this.parameters={}};g("gaia.ajax.XmlHttpFormRequest",k);
  k.prototype.send=function(a,c){var b=[],d;for(d in this.parameters)b.push(d+"="+encodeURIComponent(this.parameters[d]));b=b.join("&amp;");var f=this.a;f.open("POST",a,!0);f.setRequestHeader("Content-type","application/x-www-form-urlencoded");f.onreadystatechange=function(){4==f.readyState&amp;&amp;c({status:f.status,text:f.responseText})};f.send(b)};k.prototype.send=k.prototype.send;
  k.prototype.h=function(a,c,b){var d=this.a;d.open("POST",a,!0);d.setRequestHeader("Content-type","application/json");d.onreadystatechange=function(){4==d.readyState&amp;&amp;b({status:d.status,text:d.responseText})};d.send(c)};k.prototype.sendJson=k.prototype.h;k.prototype.get=function(a,c){var b=this.a;b.open("GET",a,!0);b.onreadystatechange=function(){4==b.readyState&amp;&amp;c({status:b.status,text:b.responseText})};b.send()};k.prototype.get=k.prototype.get;var l=/\s*;\s*/,m=function(){if(!document.cookie)return"";for(var a=document.cookie.split(l),c=0;c&lt;a.length;c++){var b=a[c];b=b.replace(/^\s+/,"");b=b.replace(/\s+$/,"");if(0==b.indexOf("APISID="))return b.substr(7)}return""};var n=null,p=function(a,c){this.g=a;this.f=c;this.c=m();this.b=!1},q=function(){var a=n,c=m();c==a.c||a.b||(a.c=c,(new k).get(a.f,function(b){var a=n;b&amp;&amp;b.status&amp;&amp;200==b.status&amp;&amp;"OK"==b.text&amp;&amp;(a.a&amp;&amp;clearInterval(a.a),a.b||(window.location=a.g))}))};p.prototype.start=function(a){if(this.a)return!1;this.a=setInterval(function(){q()},a);return!0};g("gaia.loginAutoRedirect.start",function(a,c,b){if(n||!b||!c||0&gt;=a)return!1;n=new p(c,b);return n.start(a)});
  g("gaia.loginAutoRedirect.stop",function(){var a=n;a.b=!0;a.a&amp;&amp;(clearInterval(a.a),a.a=null)});
  &lt;/script&gt;
    &lt;script type="text/javascript" nonce="0B6waBnPr4W7otWlyB0B/g"&gt;
    gaia.loginAutoRedirect.start(5000,
    'https:\x2F\x2Faccounts.google.com\x2FServiceLogin?continue=https%3A%2F%2Fdrive.google.com%2Fuc%3Fexport%3Ddownload%26id%3D1fqA6AS0PRxZm6Pny8MW9yX24eozjFxms\x26followup=https%3A%2F%2Fdrive.google.com%2Fuc%3Fexport%3Ddownload%26id%3D1fqA6AS0PRxZm6Pny8MW9yX24eozjFxms\x26service=wise\x26ltmpl=drive\x26passive=1209600\x26noautologin=true',
    'https:\x2F\x2Faccounts.google.com\x2FPassiveLoginProber?continue=https%3A%2F%2Fdrive.google.com%2Fuc%3Fexport%3Ddownload%26id%3D1fqA6AS0PRxZm6Pny8MW9yX24eozjFxms\x26followup=https%3A%2F%2Fdrive.google.com%2Fuc%3Fexport%3Ddownload%26id%3D1fqA6AS0PRxZm6Pny8MW9yX24eozjFxms\x26service=wise\x26ltmpl=drive\x26passive=1209600');
    &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I'm not sure what this means. It looks like it's trying to do something with logging in. Can someone explain what's happening and how I can download the actual file instead? </p>
  
  <p>By the way...I have tried to use Google Drive's API, but due to limitations I do not have access to their Google Platform Services, so that's not an option.</p>