1
votes

Hi I created a spreadsheet using google spreadsheet API with service account credentials (using service token).The problem is that sheet got created in the service account which I cannot access. So how can I make the sheet public? Is there any way to make a sheet public using its URL? Thanks

1

1 Answers

1
votes

For managing permissions of your drive files (spreadsheet, docs, etc), you'll be using Permissions.create where you'll set the type to "anyone". You can check thos SO post for code implementation sample.

private Permission insertPermission(Drive service, String fileId) throws Exception{
   Permission newPermission = new Permission();
   newPermission.setType("anyone");
   newPermission.setRole("reader");
   newPermission.setValue("");
   newPermission.setWithLink(true);
   return service.permissions().insert(fileId, newPermission).execute();
}