Java - Google APIs - Publishing a Document

I have a problem loading information using the Google Docs API. The challenge is to download the document and then publish it immediately after downloading. The first part I decided was to get the DocsService client, authenticate myself using the client.setUserCredentials(userName, password) method, and then load the contents using client.insert(URL, newDocument) .

At this point, the document appears in the Google folder. My problem is that I cannot figure out how to publish it. I tried to imitate the POST method (which Google creates when I click on the publication), but this did not work. I also tried using this methodology , but I could not figure out how to authenticate myself (using client.setUserCredentials ).

Is there an easy way or best practice for publishing via API?

+1
source share
1 answer

The exchange is carried out by changing the ACL of the document, additional information can be found in the developer's guide .

Using the Java client library to make a document read-only, you can:

 AclEntry aclEntry = new AclEntry(); aclEntry.setRole(AclRole.READER); aclEntry.setScope(new AclScope(AclScope.Type.DEFAULT, null)); URL url = new URL(documentEntry.getAclFeedLink().getHref); return service.insert(url, aclEntry); 
0
source

Source: https://habr.com/ru/post/1402232/


All Articles