Google云端硬盘服务帐户错误403禁止访问

时间:2015-04-27 08:54:24

标签: java google-drive-api

当我尝试将文件插入到我的驱动器共享公用文件夹时,我收到错误。

我正在使用Google Drive API for java。

我的java代码是:

File body = new File();
body.setTitle("ringeeapp");
body.setDescription("file uploadings");
body.setMimeType("text/plain");
body.setParents(Arrays.asList(new ParentReference().setId(folderId)));
java.io.File fileContent = new java.io.File("G:\\document.txt");
FileContent mediaContent = new FileContent("text/plain", fileContent);
File file = service.files().insert(body, mediaContent).execute();
System.out.print("file id is :" + file.getId());
Permission newPermission = new Permission();
// for showing files in browser that reason only using additional
// permission
newPermission.setValue("");
newPermission.setType("anyone");
newPermission.setRole("reader");
service.permissions().insert(file.getId(), newPermission).execute();
return file;

我收到以下错误:

error :`com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
  "code" : 403,
  "errors" : [ {
    "domain" : "global",
    "location" : "file.permissions",
    "locationType" : "other",
    "message" : "Insufficient permissions for this file",
    "reason" : "forbidden"
  } ],
  "message" : "Insufficient permissions for this file"
}`

如何解决这个问题?

0 个答案:

没有答案
相关问题