我正在使用服务帐户连接到我个人 Google 帐户中的共享云端硬盘。Google Drive API 始终返回错误,指出未找到共享云端硬盘。我尝试了这两个:
共享驱动器的链接采用以下格式:https://drive.google.com/drive/folders/xyz ,我假设driveId是链接的最后一部分,xyz?或者这是文件夹ID?如果是这样,我如何找到driveId?
// load the service account credentials
data, err := ioutil.ReadFile("service-account.json")
if err != nil {
log.Fatal("failed to read json file")
}
// parse the credentials file
conf, err := google.JWTConfigFromJSON(data, drive.DriveReadonlyScope)
if err != nil {
log.Fatal("failed to parse json file")
}
apiKeyBytes, err := ioutil.ReadFile("api-key.txt")
API_KEY := string(apiKeyBytes)
DRIVE_ID := "1dpl28_lhR1myDL2Y2gYKLRX1gNRlWdFm"
// send the GET request with all the parameters
client := conf.Client(context.Background())
parameters := "?key=" + API_KEY …Run Code Online (Sandbox Code Playgroud)