我在共享Google驱动器文件时遇到问题。我用这种方法
OAuth运行得很好,我可以返回文件和文件夹,但是我不能更改共享权限,这是我的很多问题,我不知道为什么
JsonBatchCallback<Permission> callback = new JsonBatchCallback<Permission>() {
@Override
public void onFailure(GoogleJsonError e,
HttpHeaders responseHeaders)
throws IOException {
// Handle error
System.err.println(e.getMessage());
}
@Override
public void onSuccess(Permission permission,
HttpHeaders responseHeaders)
throws IOException {
System.out.println("Permission ID: " + permission.getId());
}
};
BatchRequest batch = service.batch();
Permission userPermission = new Permission()
.setType("user")
.setRole("reader")
.setEmailAddress("mail@gmail.com");
service.permissions().create(file_id, userPermission)
.setFields("id")
.queue(batch, callback);
batch.execute();
是回应
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "Insufficient Permission: Request had insufficient authentication scopes.",
"reason" : "insufficientPermissions"
} ],
"message" : "Insufficient Permission: Request had insufficient authentication scopes."
}
这是我的范围
Collections.singletonList(DriveScopes.DRIVE); //"https://www.googleapis.com/auth/drive"