You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用访问令牌获取Google Drive下载链接无效求助

Troubleshooting Google Drive downloadUrl Blank Page Issue

Let’s work through this problem step by step—here are the most common fixes that should resolve why you’re seeing a blank page instead of a file download:

  • Include your Authorization header when accessing the downloadUrl
    The downloadUrl returned by Drive v2 is a signed, short-lived URL, but it still requires valid authentication to access. When you paste the URL directly into a browser, it doesn’t include your Authorization: Bearer [ACCESS_TOKEN] header, which is likely causing the blank page. Instead, use a tool like curl or Postman to make a GET request to the downloadUrl with that header included. For example:

    curl -H "Authorization: Bearer [ACCESS_TOKEN]" [your-download-url] -o downloaded-file.ext
    

    If you need to download it in a browser, you could create a small script to trigger the download with the header, or use the Drive v3 direct download method below.

  • Validate your access token scope and file permissions
    Double-check that your access token was requested with the correct scope: either https://www.googleapis.com/auth/drive.readonly (for read-only access) or https://www.googleapis.com/auth/drive (for full access). A token with a narrower scope might let you fetch the downloadUrl but block you from accessing the file content. Also, confirm the file is shared with the authenticated user (or your service account) if it’s not a publicly accessible file.

  • Switch to the Drive v3 API (recommended)
    Drive v2 is deprecated, and the v3 API offers a more reliable direct download method that skips the intermediate downloadUrl step. To download a file directly with v3, use this request:

    GET https://www.googleapis.com/drive/v3/files/[file_id]?alt=media
    

    Include the same Authorization: Bearer [ACCESS_TOKEN] header as before. This will return the file content directly, avoiding the blank page issue entirely.

  • Handle Google Workspace files separately
    If the file is a Google-native document (Docs, Sheets, Slides, etc.), you can’t use downloadUrl to get the raw file—you need to export it instead. For Drive v2, fetch the exportLinks field from the file resource (e.g., exportLinks.application/pdf for a PDF export), then make a GET request to that URL with your Authorization header. For Drive v3, use the export endpoint:

    GET https://www.googleapis.com/drive/v3/files/[file_id]/export?mimeType=application/pdf
    
  • Debug the response with browser dev tools
    If you still see a blank page, open your browser’s developer tools (F12), go to the Network tab, and reload the downloadUrl. Check the response status code (e.g., 401 for unauthorized, 403 for permission denied) and the response body—this will often have a detailed error message that points exactly to the problem.

内容的提问来源于stack exchange,提问作者Renjith

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 13:19:06