Hey everyone! I’m working on a Java app and I need some help. I want to get a list of all the files in the public folder on Google Drive. The tricky part is I don’t want to use any authentication. Is this even possible?
I’ve been looking at the Java Google Drive library, but I’m not sure if it can do what I need. Has anyone done something like this before? What’s the best way to go about it?
I’m pretty new to working with Google Drive, so any tips or code examples would be super helpful. Thanks in advance for any advice you can give!
hey, have u tried using the google drive API’s “files.list” method? it might work for public stuff without auth. just gotta set the “q” parameter to search the specific folder. but yeah, google’s docs can be confusing AF sometimes. good luck with ur project!
I’ve actually tackled a similar project before, and I can tell you it’s a bit tricky without authentication. Google Drive’s API generally requires some form of auth for security reasons. However, there’s a workaround you might consider.
Instead of using the Drive API directly, you could leverage the fact that public Google Drive folders have a web interface. You could potentially scrape this public webpage to extract file information. It’s not as clean as using the API, but it might work for your needs.
You’d need to use a library like JSoup to parse the HTML of the public folder page. Be aware this method isn’t officially supported by Google and could break if they change their page structure. Also, it might not work for very large folders.
If you absolutely need to use the API, you might have to look into using a service account with domain-wide authority, but that’s a whole other can of worms. Hope this gives you some ideas to explore!
While accessing Google Drive’s public directory without authentication is challenging, there’s an alternative approach you might consider. Instead of using the Google Drive API, you could utilize the Google Drive SDK for Java, which provides methods to interact with public files and folders without requiring user authentication.
To implement this, you’d need to obtain the folder ID of the public directory you want to access and use the SDK’s search functionality to retrieve a list of files within that folder. Keep in mind that this method only works for publicly shared content and has its limitations regarding the volume of retrievable data.
Bear in mind that Google occasionally updates its APIs and SDKs, so it is important to refer to the latest documentation and be prepared to handle rate limiting or other restrictions on unauthenticated requests.