I’m building an app that needs to access all files within a folder that users pick through Google Picker. The user should be able to choose any folder from their Google Drive using the picker interface.
I’ve been looking at the API documentation and it seems like the drive.file scope might work for what I need. However, I’m confused about how to properly configure the backend code to work with the specific folder that gets selected on the frontend side.
Can someone explain the proper way to set this up? I want to make sure the backend can read all the files from whatever folder the user selects through the picker component.
The problem is that drive.file scope only lets you access files your app created or files users specifically opened with your app. You need drive.readonly scope to access all files in a user-selected folder. After the user picks a folder through the Picker, you’ll get a folder ID to send to your backend. Your backend should use the Drive API’s files.list method with the q parameter set to '${folderId}' in parents to grab all files in that folder. Just make sure your backend OAuth flow uses the same credentials and scopes as your frontend picker.
Had this exact problem last month. The scope thing’s trickier than it looks - ameliat’s right that drive.readonly is safer, but there’s another way that worked for me. Use drive.file scope and have the user grant folder access through the picker with the right config. Set enableFeatures to include ‘MULTISELECT_ENABLED’ and make sure your picker config includes the folder in selection. Once you’ve got the folder ID on the backend, handle cases where files aren’t accessible due to permissions. I built a fallback that prompts users to reshare folders when the API throws permission errors. Key is solid error handling since Drive permissions are inconsistent.
for sure! just get that folder ID from the picker, then hit up the Drive API to get the files. don’t forget to set your backend with the right oauth tokens using the drive.file scope, otherwise it might not work properly.