我想通过使用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))
我得到了这个错误提示器,谢谢您的帮助。
{"error": {"code": 404, "errors": [[Object]], "message": "Shared drive not found: 1YAyXfzIAOP5TejUW00RR9jhXaBIXKF8_"}}
固定? 我提供的是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))
答案 0 :(得分:0)
配置“driveId”用于通过驱动器ID查找。将您的配置更改为:
--
'q' => "'" . {{YOUR_FOLDER_ID_HERE}} . "' in parents",
'fields' => "*"
--