title: Programmatically Download Content from Drive Share Links
body: <p>
  I'm building an application to automatically trigger a download of a file share with a user. For example, this was straight forward to implement for Dropbox links, as is outlined <a href="https://www.dropbox.com/developers/blog/53/programmatically-download-content-from-share-links" rel="nofollow">here</a>.
  </p>
  
  <p>
  I'm trying to implement the same functionality for Google Drive links, but running into difficulties. Right now the app takes the third part of the link (the file ID) and appends it to "https://docs.google.com/uc?export=download&id= ". But this seems unreliable, especially as there are at least 3 different link formats for shared files that I've found (https://drive.google.com/file/d/xyz, https://docs.google.com/document/d/xyz etc.). Does anyone know of a generally applicable and reliable way to grab the files from Google Drive shared links, like the process outlined for Dropbox above? 
  </p>
  
  <p>
  Finally, we have Oauth access to a users Drive account. For files shared with them that have sharing settings set to 'Private' (or anything other than 'Public on the web' or 'Anyone with the link'), I've been researching (with little success) if it is possible to download those files on behalf of the Oauth authenticated user - does anyone have any insight on this?
  </p>
  
  <p>Any insight/suggestions would be greatly appreciated.</p>
  
  <p><strong>[Update]</strong> The "private" shared files can be downloaded from the users Drive account - they're automatically added to the 'Shared with me folder', so just need a reliable way to grab the file ID.</p>