Hey everyone, I need some help with Google Drive.
I’m trying to figure out if there’s a way to get a list of files from a public Google Drive folder without going through the whole authorization process. I know it’s possible to share folders publicly, but I’m not sure how to access the file list programmatically.
Here’s what I’m aiming for: I want to use a public Google Drive folder to store images for a gallery on my website. It would be great if I could automatically fetch the file names or URLs without needing to authenticate every time.
Has anyone navigated this before? Any tips or suggestions would be really helpful. Thanks in advance!
I’ve actually tackled this issue before in a project. While Google doesn’t provide a direct method to list files in a public folder without authentication, there’s a workaround that might help. You can use the Google Drive API’s ‘files.list’ method with the folder’s ID, but you’ll need to set up a service account.
Here’s the gist: Create a service account in Google Cloud Console, give it access to the Drive API, and share your public folder with the service account’s email. Then, use the service account’s credentials in your code to authenticate and list the files. This way, your website can fetch the file list without user intervention.
It’s a bit more setup initially, but once it’s done, you won’t need to worry about authentication again. Just keep the service account credentials secure. This approach has worked well for me in similar scenarios.
While it’s possible to access individual files in a public Google Drive folder without authentication, getting a comprehensive list of files programmatically isn’t straightforward without using the API. One workaround I’ve used is to create a Google Apps Script that runs on a time-based trigger. It can generate a JSON file with the folder’s contents and save it in the same public folder. Your website can then fetch this JSON file to get an up-to-date list of files. It’s not real-time, but it’s a decent compromise if you want to avoid authentication. Just remember to set appropriate sharing permissions on both the folder and the script.
hey there, i’ve got a quick trick for ya. you can actually use the google sheets API instead. make a sheet in the public folder, use a formula to list all files, then fetch that sheet’s data. it’s a bit hacky but works like a charm. no auth needed!