title: How to download a file via the Google Drive API?
body: <p>I'm working to download a file via the Google Drive API using the gem google-api-client.</p>
  
  <pre><code>x = Google::Apis::DriveV2
  drive = x::DriveService.new
  drive.authorization = auth
  
  files = drive.list_files
  files.items.each_with_index do |file, index|
      url_to_index = file.export_links.select { |k, v| v if k == 'text/plain' }
      file_content =  open(url_to_index["text/plain"]).read
  end
  </code></pre>
  
  <p>The problem is file_content is returning the Google login screen not the file in text/plain format. It appears that when my Rails app opens the URL it does not have access to the text file.</p>
  
  <p>What's the right way to enable my Rails app to grab the file in the text format?</p>