I have files on Google Drive what I shared to public. I see this example in Google documentation https://developers.google.com/drive/api/reference/rest/v3/files/get
How I can download public file from Google Drive without autentication
```export async function downloadFile(realFileId) {
// Get credentials and build service
// TODO (developer) - Use appropriate auth mechanism for your app
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive.file',
});
const service = google.drive({version: 'v3', auth});
let fileId = realFileId;
try {
const file = await service.files.get({
fileId: fileId,
alt: 'media',
});
console.log(file.status);
return file.status;
} catch (err) {
// TODO(developer) - Handle error
throw err;
}}```
I know fileID and reproduce code from example and receive error "GaxiosError: Insufficient Permission" - what wrong?
Solved! Go to Solution.
Google Drive is not a hosting service for public files. Use of the API requires an association of a Google Cloud Project to the API call via API Key or other credentials.
Add an API key to the request.
{
key: "YOUR_API_KEY",
fileId: fileId,
alt: 'media',
}
Thanks, @jpoehnelt Do you mean API key in Google Cloud? In this case I can not understand what relation between Google Drive and Google Cloud? I don't see any API key in Google Drive. Google cloud, what manage API key - is absolutely another service with another requirements. I must create project, I must pass my phone to Google, I must pass full identification with passport and my home address what must accept Google, than must upload my bank account to Google.
But I just want to download PUBLIC file, shared for everyone from Google Drive.
Or I use wrong API? Currently I need download file from Google Drive (shared to anyone), do I need upload passport and bank card to Google to login to Google Cloud - just for download public file from Google Drive?
I try to use link similar to https://googledrive.com/host/1M88r7TS5uZkDrWj-3SZ9AoQQtBXOfyPD/.vscode/settings.json
where 1M88r7TS5uZkDrWj-3SZ9AoQQtBXOfyPD my public folder ID and .vscode is folder and settings.json is filename - but unfortunately this URL format is not working. Therefore I found API. Documentation for Google drive not mention anything about API key to access to Google Drive.
Shared for everyone means that any anonymous user can download my file, isn't it? Can I download my file without pass identification in Google Cloud, anonymously?
Google Drive is not a hosting service for public files. Use of the API requires an association of a Google Cloud Project to the API call via API Key or other credentials.
thanks, but this is very strange, of course Google Drive is EXACTLY place to share any public files
Also Google drive allow to create public website, of course this is public place to create public sites - https://sites.google.com/ exactly the service what allow to share Google Drive to public as public website.