Google Drive moved its download endpoint to drive.usercontent.google.com. Older drive.google.com/uc?…&confirm=t commands now redirect and drop confirm=t, so they save a “Virus scan warning” HTML page instead of your file.
Methods in this guide:
- curl and wget for public files
- gdown for Python users, folders and Docs exports
- The Drive API for private files
Why large files fail to download
Use this section if your download finishes instantly and the file is only a few KB.
For files that are too large for Google to virus-scan, Drive shows a confirmation page instead of starting the download. A browser shows you a Download anyway button. curl and wget can’t click it, so they save the HTML page.
Google doesn’t publish the exact size at which this starts. Treat any file over roughly 100 MB as likely to need the steps below; small files often download without them.
Note: On 19 October 2026 we checked the old form,
https://drive.google.com/uc?export=download&id=FILE_ID&confirm=t. It returned a 303 redirect todrive.usercontent.google.comwithoutconfirm=t, and the page that came back was titled “Google Drive - Virus scan warning”.
Prerequisites: build the direct download URL
Use this before any curl, wget or gdown command.
- In Google Drive, right-click the file and choose Share. Under General access, select Anyone with the link.
- Copy the link. The file ID is the part between
/d/and/view.- In
https://drive.google.com/file/d/19eYCYiVuJ3CgYwfAeYB2tG_RfdoJPAHZ/view?usp=sharing, the ID is19eYCYiVuJ3CgYwfAeYB2tG_RfdoJPAHZ. - If you can’t find the file, here’s how to find the file’s folder in Drive.
- In
- Put the ID into this URL:
https://drive.usercontent.google.com/download?id=FILE_ID&export=download&confirm=tResult: A URL that returns the file itself. With our 100 MB sample PDF it returned application/octet-stream with the original filename in the Content-Disposition header.
If you need direct links for many files at once, this video shows how to generate them in bulk:
Downloading large files using curl
Use this when you want a single command that works in scripts, CI jobs and servers. curl ships with macOS, current Windows 10 and 11 builds, and most Linux distributions.
- Open a terminal.
- Run the command with your file ID:
curl -L -o largefile.pdf "https://drive.usercontent.google.com/download?id=19eYCYiVuJ3CgYwfAeYB2tG_RfdoJPAHZ&export=download&confirm=t"- To keep Google’s filename instead of choosing one, replace
-o largefile.pdfwith-OJ.
What the options do:
-Lfollows redirects.-o largefile.pdfwrites the download to that file.-OJsaves the file using the name in theContent-Dispositionheader.- Quote the URL, because
&has a special meaning in the shell.
Result: curl shows a progress meter and saves the file. Check it with file largefile.pdf; if it says “HTML document”, the URL is wrong or the file isn’t public.
Tip: If the connection drops, run the same command with
-C -added. curl resumes from the end of the partial file.
Downloading large files using wget
Use this when wget is already part of your tooling, for example in cron jobs or minimal Linux images. See the GNU Wget manual for every option.
- Open a terminal.
- Run:
wget --content-disposition "https://drive.usercontent.google.com/download?id=19eYCYiVuJ3CgYwfAeYB2tG_RfdoJPAHZ&export=download&confirm=t"What the options do:
--content-dispositionsaves the file with the name Google sends (for our sample,sampledocs-100mb-pdf-file.pdf).- Use
-O largefile.pdfinstead if you want to set the name yourself. - Add
-cto resume an interrupted download.
Result: wget prints the response, the file length and a progress bar, then saves the file in the current folder.
Downloading large files using gdown
Use this when you work in Python, need a whole folder, or want to export a Google Doc or Sheet. gdown handles the confirmation page for you, so you don’t need to build the usercontent URL.
- Install it (current versions need Python 3.10 or later):
pip install gdown- Download by file ID or by the share link:
gdown 19eYCYiVuJ3CgYwfAeYB2tG_RfdoJPAHZgdown "https://drive.google.com/file/d/19eYCYiVuJ3CgYwfAeYB2tG_RfdoJPAHZ/view?usp=sharing"- Download a public folder, or resume a partial file:
gdown https://drive.google.com/drive/folders/FOLDER_ID -O ./my-foldergdown 19eYCYiVuJ3CgYwfAeYB2tG_RfdoJPAHZ --continueIn a Python script:
import gdown
gdown.download(id="19eYCYiVuJ3CgYwfAeYB2tG_RfdoJPAHZ", output="largefile.pdf")Result: gdown prints the source URL and a progress bar, then saves the file.
Note: A bare folder ID needs
--folder, because file IDs and folder IDs look the same. Folder URLs are detected automatically.
Downloading Google Docs and Sheets files
Use this when the file is a native Google Doc, Sheet or Slides file rather than an uploaded PDF or ZIP. These files have no binary to download, so you request an export instead.
- Public Google Doc as PDF:
curl -L -o doc.pdf "https://docs.google.com/document/d/DOC_ID/export?format=pdf" - With gdown: pass the Docs, Sheets or Slides URL. Docs export to
.docxby default; add--format pdffor a PDF. - Private files: use the Drive API’s
files.exportmethod. Google caps exported content at 10 MB.
If you only need one document, it’s often quicker to export a Google Doc as a PDF from the Docs menu.
Downloading private files using the Google Drive API
Use this when the file isn’t shared publicly, or you need downloads inside an application. The Drive API download guide documents every option.
Quick curl call with an access token
If you already have an OAuth access token with a Drive scope, curl can call the API directly:
curl -L "https://www.googleapis.com/drive/v3/files/FILE_ID?alt=media" \ --header "Authorization: Bearer ACCESS_TOKEN" \ --output largefile.pdfPython script with OAuth
- In the Google Cloud Console, create or select a project.
- Go to APIs & Services → Library, search for Google Drive API and click Enable.
- Go to Google Auth platform → Branding and set up the OAuth consent screen.
- Go to Google Auth platform → Clients → Create Client, choose Desktop app, and save the downloaded JSON file as
credentials.json. Google’s Drive API Python quickstart walks through these screens. - Install the client libraries:
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib- Save and run this script:
import os
from google.auth.transport.requests import Requestfrom google.oauth2.credentials import Credentialsfrom google_auth_oauthlib.flow import InstalledAppFlowfrom googleapiclient.discovery import buildfrom googleapiclient.http import MediaIoBaseDownload
SCOPES = ["https://www.googleapis.com/auth/drive.readonly"]
def get_service(): creds = None if os.path.exists("token.json"): creds = Credentials.from_authorized_user_file("token.json", SCOPES) if not creds or not creds.valid: if creds and creds.expired and creds.refresh_token: creds.refresh(Request()) else: flow = InstalledAppFlow.from_client_secrets_file("credentials.json", SCOPES) creds = flow.run_local_server(port=0) with open("token.json", "w") as token: token.write(creds.to_json()) return build("drive", "v3", credentials=creds)
def download_file(service, file_id, destination): request = service.files().get_media(fileId=file_id) with open(destination, "wb") as fh: downloader = MediaIoBaseDownload(fh, request) done = False while not done: status, done = downloader.next_chunk() print(f"Download {int(status.progress() * 100)}%")
if __name__ == "__main__": service = get_service() download_file(service, "FILE_ID", "largefile.pdf") print("Saved largefile.pdf")Result: The first run opens a browser so you can sign in and allow access. It then saves token.json, so later runs download without a prompt.
Note:
get_mediaworks for uploaded files such as PDFs, ZIPs and videos. For Google Docs, Sheets and Slides, usefiles().export_media(fileId=..., mimeType="application/pdf")instead.
Comparing the download methods
| Method | Best for | Works on |
|---|---|---|
| curl + usercontent URL | One-line downloads in scripts and servers | Public files; macOS, Windows, Linux |
| wget + usercontent URL | Cron jobs and minimal Linux images | Public files; mainly Linux and macOS |
| gdown | Python projects, folders, Docs/Sheets exports | Public files; anywhere Python 3.10+ runs |
| Drive API (OAuth) | Private files and applications | Any file you can access; any language with a client library |
All four can resume: curl -C -, wget -c, gdown --continue, and the API’s chunked or Range downloads.
Automating downloads with a script
Use this when you download the same files often, such as datasets or build artifacts.
#!/bin/bash# Download a public Google Drive file with curlFILE_ID="19eYCYiVuJ3CgYwfAeYB2tG_RfdoJPAHZ"FILE_NAME="largefile.pdf"
curl -L -C - -o "${FILE_NAME}" \ "https://drive.usercontent.google.com/download?id=${FILE_ID}&export=download&confirm=t"
if file "${FILE_NAME}" | grep -q HTML; then echo "Got an HTML page instead of the file. Check sharing and the file ID." >&2 exit 1fiecho "Download complete: ${FILE_NAME}"The final check catches the most common failure: a saved warning or sign-in page.
Troubleshooting common errors
- The file is a few KB of HTML. You hit the virus-scan page or a sign-in page. Use the usercontent URL with
confirm=t, and confirm the file is shared with Anyone with the link. - 403 or “access denied”. The file is private, or your organization blocks public sharing. Use the Drive API with an access token.
- “Too many users have viewed or downloaded this file recently”. The public link hit a temporary limit. Google’s Download a file help page says it usually resets within 24 hours.
- The download stops partway. Re-run with
curl -C -orwget -cto resume. - The filename is wrong. Use
curl -OJorwget --content-dispositionto keep Google’s name.
Security considerations
Skipping the scan warning means Google hasn’t checked the file for malware.
- Only download files from people or projects you trust.
- Scan the file locally before you open or run it.
- Share public links narrowly, because anyone with the link can download the file.
For more Drive and Docs how-tos, see the Google Docs and Drive guides.