1

I am trying to get the shared drive id in the callback of the google picker. The response I am getting is attached in screenshotenter image description here

These are the scopes for getting the drive data These are the scopes for getting the drive data

Following is the code for creating picker

let view = new google.picker.DocsView()
            .setOwnedByMe(false)
            .setParent(vm.folderLocationId)
            .setEnableDrives(true)
            .setMimeTypes('application/vnd.google-apps.folder')
            .setSelectFolderEnabled(true);

const picker = new google.picker.PickerBuilder()
          .enableFeature(google.picker.Feature.NAV_HIDDEN)
          .enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
          .enableFeature(google.picker.Feature.SUPPORT_DRIVES)
          .setDeveloperKey(vm.api_key)
          .setAppId(APP_ID)
          .setOAuthToken(vm.access_token)
          .addView(view)
          .addView(new google.picker.DocsUploadView())
          .setCallback(pickerCallback)
          .build();
      picker.setVisible(true);

async function pickerCallback(data) {
  console.log('data', data)
}

This is the response of console.log enter image description here

I am using gapi not google drive api for doing this.

Please let me know what I am doing wrong.

Thanks

Yisal Khan
  • 359
  • 3
  • 10
  • Can you provide your existing code along with the error you encountered so that we can replicate your problem? – George Mar 16 '23 at 05:27
  • @George I have added more details to the question. Please have a look. Thanks – Yisal Khan Mar 16 '23 at 06:54
  • Have you tried [Implementing shared drive support](https://developers.google.com/drive/api/guides/enable-shareddrives#drive-api-v3)? In your `pickerCallback` function you can use the [files.list](https://developers.google.com/drive/api/guides/enable-shareddrives#search_for_content_on_a_shared_drive) method to search for shared drives and include `supportAllDrives=true` in your request – George Mar 17 '23 at 03:16
  • @George I have already checked this out. But for files.list, I need driveId which I am unable to get in the data of the callback of the picker. – Yisal Khan Mar 17 '23 at 09:28
  • By any chance, is this [link](https://stackoverflow.com/questions/58231453/google-drive-picker-use-feature-mine-only-along-with-feature-support-drives?rq=1) helpful in any way to your problem? – George Mar 18 '23 at 06:58

1 Answers1

1

As I was trying to get the drive id by which I can access the folders of the shared drive.

I did it by adding the parameter of supportsAllDrives: true

enter image description here

Yisal Khan
  • 359
  • 3
  • 10