Ahm*_*med 6 google-drive-android-api react-native
我想通过使用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)
配置“driveId”用于按驱动器 ID 查找。将您的配置更改为:
--
'q' => "'" . {{YOUR_FOLDER_ID_HERE}} . "' in parents",
'fields' => "*"
--
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4646 次 |
| 最近记录: |