When the API key is used for downloading the publicly shared file, how about this answer? At webContentLink
like https://drive.google.com/uc?id=### fileId ###&export=download
, such issue occurs. So in this case, it uses the method of Files: get in Drive API.
Endpoint:
https://www.googleapis.com/drive/v3/files/### fileId ###?alt=media&key=### API key ###
Sample curl command:
curl "https://www.googleapis.com/drive/v3/files/### fileId ###?alt=media&key=### API key ###"
- Of course, you can download the file by accessing to the endpoint of
https://www.googleapis.com/drive/v3/files/### fileId ###?alt=media&key=### API key ###
with your browser.
Note:
- In above endpoint, the file is required to be shared publicly. Please be careful this.
- In this case, Drive API is used. So please enable Drive API at API console.
References: