Accessing Google Docs without specific document IDs

I’m working on a Chrome add-on that lets users save highlighted text to their Google Docs. The plan is to show a list of their recent docs or let them search for one. But I’m stuck.

I’ve looked at the Chrome identity stuff, Docs API, and Drive API. They all talk about needing the doc’s ID. Is there really no way to get a list of docs without knowing these IDs first? Seems like it might be a privacy thing, but I’m not sure.

Does anyone know if this is possible? Or am I barking up the wrong tree here?

I thought I might need to use the Drive API to list files, but I’m not 100% sure that’s the right approach. Any help would be awesome!

I have experience with similar projects and found that using the Drive API is a solid approach. In my case, I used the files.list method to retrieve the user’s documents without knowing their IDs in advance. It’s important that you filter the results to focus on Google Docs files. Also, make sure you request the proper OAuth scopes, like the drive.readonly scope, to avoid any permission issues. You might also want to implement pagination if there are many documents, which helps keep the add-on responsive.

You’re definitely on the right path with the Drive API. I’ve implemented something similar, and it works well for accessing Docs without knowing specific IDs. Here’s what I found helpful:

Use the files.list method with a query parameter to filter for only Google Docs files. Something like ‘mimeType=‘application/vnd.google-apps.document’’ works well.

For the OAuth scope, I’d recommend using ‘https://www.googleapis.com/auth/drive.readonly’ if you’re just reading files. It’s more privacy-friendly for users.

One tip: consider caching the list of documents locally and refreshing periodically. It can significantly improve your add-on’s performance, especially for users with lots of docs.

Remember to handle potential API errors gracefully. Google’s services are reliable, but network issues can always crop up.

hey mikezhang, you’re on the right track with the Drive API. it’s what you need to list files, including Docs. you can use the ‘files.list’ method to get doc IDs, then use those with the Docs API. just make sure you request the right scopes when setting up auth. good luck with your add-on!