Google 驱动 API files.get 迁移到 HTTP "webViewLink" - 如何绕过 100mb 病毒页面?
Google Drive API with files.get migrating to HTTP "webViewLink" - how to bypass 100mb virus page?
Google 发布 this blog post 其中说:
If you authorize download requests to the Drive API using the access
token in a query parameter, you will need to migrate your requests to
authenticate using an HTTP header instead. Starting January 1, 2020,
download calls to files.get, revisions.get and files.export endpoints
which authenticate using the access token in the query parameter will
no longer be supported, which means you’ll need to update your
authentication method.
然后说:
For file downloads, redirect to the webContentLink which will instruct
the browser to download the content. If the application wants to
display the file to the user, they can simply redirect to the
alternateLink in v2 or webViewLink in v3.
但是,如果我们使用 webContentLink,那么我们将点击 。
我可以看到迁移已被延迟,但迟早会发生,我们希望应用程序面向未来。
实施此更改后,我们如何才能在不达到 100mb 病毒限制的情况下下载内容?
If you authorize download requests to the Drive API using the access token in a query parameter, you will need to migrate your requests to authenticate using an HTTP header instead.
示例查询参数:
GET https://www.googleapis.com/drive/v3/files/[FILEID]?access_token=[YOUR_ACCESS_TOKEN] HTTP/1.1
Accept: application/json
示例请求 header:
GET https://www.googleapis.com/drive/v3/files/[FILEID] HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
假设您可以使用 http header 选项,那么上述下载应该不会有任何问题。只有在您无法添加授权 header 时才会出现下载问题。在这种情况下,我认为您需要使用第二个选项并直接导出文件。
Google 发布 this blog post 其中说:
If you authorize download requests to the Drive API using the access token in a query parameter, you will need to migrate your requests to authenticate using an HTTP header instead. Starting January 1, 2020, download calls to files.get, revisions.get and files.export endpoints which authenticate using the access token in the query parameter will no longer be supported, which means you’ll need to update your authentication method.
然后说:
For file downloads, redirect to the webContentLink which will instruct the browser to download the content. If the application wants to display the file to the user, they can simply redirect to the alternateLink in v2 or webViewLink in v3.
但是,如果我们使用 webContentLink,那么我们将点击
我可以看到迁移已被延迟,但迟早会发生,我们希望应用程序面向未来。
实施此更改后,我们如何才能在不达到 100mb 病毒限制的情况下下载内容?
If you authorize download requests to the Drive API using the access token in a query parameter, you will need to migrate your requests to authenticate using an HTTP header instead.
示例查询参数:
GET https://www.googleapis.com/drive/v3/files/[FILEID]?access_token=[YOUR_ACCESS_TOKEN] HTTP/1.1
Accept: application/json
示例请求 header:
GET https://www.googleapis.com/drive/v3/files/[FILEID] HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
假设您可以使用 http header 选项,那么上述下载应该不会有任何问题。只有在您无法添加授权 header 时才会出现下载问题。在这种情况下,我认为您需要使用第二个选项并直接导出文件。