我有一个在执行以下代码时失败的PHP脚本(404,[FILE]找不到):
$result = $service->changes->getStartPageToken() ;
$nextStartPageToken = $result->startPageToken ;
$rootResult = $service->files->get('root')
故障出现在最后一行,错误日志(log)显示:
[13-Aug-2023 20:24:47 America/New_York] PHP Fatal error: Uncaught Google\Service\Exception: {
"error": {
"code": 404,
"message": "File not found: 0AORSlah_iew_Uk9PVA.",
"errors": [
{
"message": "File not found: 0AORSlah_iew_Uk9PVA.",
"domain": "global",
"reason": "notFound",
"location": "fileId",
"locationType": "parameter"
}
]
}
}
in /www/cgi-bin/GoogleRelated/vendor/google/apiclient/src/Http/REST.php:134
Stack trace:
#0 /www/cgi-bin/GoogleRelated/vendor/google/apiclient/src/Http/REST.php(107): Google\Http\REST::decodeHttpResponse()
#1 [internal function]: Google\Http\REST::doExecute()
#2 /www/cgi-bin/GoogleRelated/vendor/google/apiclient/src/Task/Runner.php(187): call_user_func_array()
#3 /www/cgi-bin/GoogleRelated/vendor/google/apiclient/src/Http/REST.php(66): Google\Task\Runner->run()
#4 /www/cgi-bin/GoogleRelated/vendor/google/apiclient/src/Client.php(922): Google\Http\REST::execute()
#5 /www/cgi-bin/GoogleRelated/vendor/google/apiclient/src/Service/Resource.php(238): Google\Client->execute()
#6 /www/cgi-bin/GoogleRelated/vendor/google/apiclient-services/src/Drive/Resource/Files.php(205): Google\Service\Resource->call()
#7 /www/htdocs/gdrive/catchupSongBook(592): Google\Service\Drive\Resource\Files->get()
#8 /www/htdocs/gdrive/catchupSongBook(80): getRootFolderId()
#9 {main}
thrown in /www/cgi-bin/GoogleRelated/vendor/google/apiclient/src/Http/REST.php on line 134
使用不同的项目JSON文件,我有一个可以成功执行相同代码(以及更多代码)的工作脚本.
由于似乎不可能有一个没有"根"文件夹的Google驱动器(因此,错误消息听起来具有误导性),我认为这里的问题在于使用的作用域或项目本身,但我看不出我当前的 Select 或项目属性有任何问题.我看过这样的答案:this one, for java个答案表明这是正确的方法,但没有找到更好的方法来实现我在这里需要的东西.
我要求的范围是:
"https://www.googleapis.com/auth/drive.appdata"
"https://www.googleapis.com/auth/drive.appfolder"
"https://www.googleapis.com/auth/drive.file"
"https://www.googleapis.com/auth/drive.resource"
真的,我有三个问题.
首先,该问题是否可能与作用域有关
第二,上面的列表是否缺少我需要的东西
第三,有没有办法查看实际授予了哪些作用域,而不仅仅是请求了什么?