小编Ahm*_*med的帖子

使用 GDrive.files.list({)) 时找不到共享驱动器

我想通过使用react-native-google-drive-api-wrapper库从共享驱动器获取文件列表,但我收到错误。这是我的代码。

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))
Run Code Online (Sandbox Code Playgroud)

我收到这个错误,谢谢您的帮助。

{"error": {"code": 404, "errors": [[Object]], "message": "Shared drive not found: 1YAyXfzIAOP5TejUW00RR9jhXaBIXKF8_"}}
Run Code Online (Sandbox Code Playgroud)

已修复 我提供了folderId而不是driveId,因此您必须像这样更改查询:

GDrive.init()
       GDrive.files.list({
       q: "' folderId ' in parents",
      })
       .then(res=>res.json())
       .then(data=>console.log(data))
       .catch(err=>console.log(err))
Run Code Online (Sandbox Code Playgroud)

google-drive-android-api react-native

6
推荐指数
1
解决办法
4646
查看次数