RobinBobin / react-native-google-drive-api-wrapper

This wrapper facilitates the use of the Google Drive API in React Native projects.
110 stars 43 forks source link

"Shared drive not found:" while using GDrive.files.list({)) #19

Closed Ahmed-ab96 closed 4 years ago

Ahmed-ab96 commented 4 years ago

hello, I want to get list of files from shared drive, but its desn't work

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))

this error occured: {"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))
RobinBobin commented 4 years ago

Hello!

You mix async / await approach with .then() / .catch(). There might be a bug hiding somewhere in there. Maybe it will be easier to debug if you rewrite with either async / await or .then() / .catch() ?

Ahmed-ab96 commented 4 years ago

Thanks for reply.. i changed code to .then() / .catch(), but its the same "shared drive not found", i think the poblem is driveId, i will try to fix this. 😢