6

I want to get list of files from shared drive, by using react-native-google-drive-api-wrapper library, but i am getting an errorr. here my code.

GoogleSignin.configure({
  scopes: [
  'https://www.googleapis.com/auth/drive',
  'https://www.googleapis.com/auth/drive.file',
],
      webClientId:"xxxxxxx",
      offlineAccess: true,
      //forceConsentPrompt: true,
 })
    await GoogleSignin.getTokens().then(res=>GDrive.setAccessToken(res.accessToken))
          GDrive.init()
          await GDrive.files.list({
            q: "mimeType='application/pdf'",
            fieIds:'*',
            corpora:'drive',
            supportsAllDrives:true,
            includeItemsFromAllDrives:true,
            driveId:'1YAyXfzIAOP5TejUW00RR9jhXaBIXKF8_'
          })
           .then(res=>res.json())
           .then(data=>console.log(data))
           .catch(err=>console.log(err))

I get this errorr, thanks for help.

{"error": {"code": 404, "errors": [[Object]], "message": "Shared drive not found: 1YAyXfzIAOP5TejUW00RR9jhXaBIXKF8_"}}

fixed I provided folderId instead driveId, so you have to change query like this:

GDrive.init()
       GDrive.files.list({
       q: "' folderId ' in parents",
      })
       .then(res=>res.json())
       .then(data=>console.log(data))
       .catch(err=>console.log(err))
Ahmed
  • 142
  • 2
  • 11
  • The `driveId` you are providing does not exist (it's not that you do not have access to it, but it simply doesn't exist). My assumption is that you are providing a `folderId` instead. Make sure that's not the case. – Iamblichus Feb 27 '20 at 09:31
  • @Iamblichus Thanks for replay. i google it to find driveId, but it said folder is driveId look at this: https://umzuzu.com/blog/2019/9/30/how-to-get-the-id-of-a-google-shared-drive-formerly-team-drives – Ahmed Feb 27 '20 at 18:34
  • 1
    Thank you i was wrong... – Ahmed Feb 29 '20 at 16:00
  • 1
    As you hav esolved the problem. Could you please post it as a solution? Refer to [this page], about answering own questions. – Raserhin Mar 09 '20 at 10:49

1 Answers1

3

Config "driveId" is used to find by Drive ID. Change your config to:

      --
      'q' => "'" . {{YOUR_FOLDER_ID_HERE}} . "' in parents",
      'fields' => "*"
      --
Trần Hữu Hiền
  • 872
  • 1
  • 9
  • 22