小编Jus*_*rry的帖子

Google Drive API 错误 - “消息”:“未找到共享驱动器:xyz”

我正在使用服务帐户连接到我个人 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)

go google-drive-api

4
推荐指数
1
解决办法
3073
查看次数

标签 统计

go ×1

google-drive-api ×1