The Google Documents List API allows client applications to view and manipulate files in a user’s Documents List.
In this blog we would learn how to share documents and files between the Google Apps Domain.
When our application requests non-public user data, it must include an authorization token. The token also identifies your application to Google. Requests to the Google Documents List Data API for non-public user data must be authorized by an authenticated user. Here, OAuth authorization is used to authorize Documents List Data API as following:
Document and collection sharing is controlled via the access control list feed. Access control lists are just basic lists that show who has access to a given resource. In the ACL feed, different type of roles scopes are available for a given document or folder.
Document’s resource_id is required to share any document with other. Resource_id is the alphanumeric key, which shows in the url as ‘/d/<…resource_id…>/’. Authenticated user’s documents and files’s resource_id can be accessed by sending an authorized GET request as following:
The result is a feed that lists the user’s documents and files, each entry in the feed represents a resource associated with the user.
We can get particular docs’s resource_id by parse the json result. Then use split() to get document’s resource_id in each entry as follow:
Post the following request to share document with user:
Here is the complete code:
This script would share your all documents and files with another user. It also sends a notification mail to user (to whom docs is shared). If that user already accessed that document , a 409 server error would occurred. Here, try-catch is used to resolve this problem.
To know more about it Click Here
I want to to thank you for this wonderful read!! I absolutely enjoyed every
little bit of it. I’ve got you book-marked to look at new stuff you post…