Accessing publicly shared Google Drive files through API without login

I’m wondering if it’s possible to retrieve files that have been set to public access on Google Drive through their API without needing to authenticate first.

I’m aware of the downloadUrl field but that gives me a temporary link and I’m not sure how long it stays valid. What I really want is to make direct API calls to fetch these public files. I think I saw someone mention before that you can make unauthenticated requests to the Google Drive API specifically for getting publicly available files but I can’t find clear documentation on this.

Has anyone successfully done this or know if it’s actually supported?

Yes, it’s possible to access public Google Drive files via the API without authentication. You can utilize the files.get endpoint using the file ID together with your API key, eliminating the need for OAuth tokens. From my experience in various projects, this method effectively handles truly public files. You’ll need the file ID, which can be extracted from the shareable link. The API will provide a webContentLink that contains a direct download URL. Just be cautious about rate limits since those requests are unauthenticated, and if the file owner alters sharing settings, your access will be interrupted. Regarding the downloadUrl, it typically remains valid for several hours, which could suit your needs depending on the use case.

hit the Drive API with ur API key and file ID - no OAuth needed for public files. i usually do GET https://www.googleapis.com/drive/v3/files/{fileId}?key={apiKey} and it works fine. the webContentLink you get back is solid, way better than temp URLs. just make sure the file’s actually shared publicly or you’ll get a 403.

I’ve used the Google Drive API with public files tons of times - this definitely works. Just use files.get with the fields parameter to grab exactly what you need: fields=webContentLink,name,mimeType. Way faster and cuts down on data transfer. Quick tip: webContentLink is different from downloadUrl - it’s more stable and built for programmatic stuff. I always check file permissions through the API first to make sure it’s actually public before trying to download. Heads up though - Google Docs and similar files need export endpoints instead of direct download links, so you’ll need to handle those separately if that’s what you’re working with.