0

I have created a web app which is making use of Google Drive API/ REST v2 (https://developers.google.com/drive/v2/web/about-sdk) to perform actions such as create/update/rename/delete of documents etc. I am authorizing requests with OAuth 2.0 (client side - that means every access token is valid for ~1h and then silently I am getting a new token) and then perform previous actions using that token.

I have a new requirement for the authorized user to share his/her documents for writing/updating them (I found out that API has option for inserting permissions (https://developers.google.com/drive/v2/reference/permissions/insert : role: writer, type: anyone).

Is it possible for a non-authenticated user to be able to write/update documents (programmatically - via Google Drive API v2 or another API?) that have been created from the authenticated user that shared these? (something that is similar to google docs/ sharing when a user is sharing his document and offline users are able to edit it?

Thanks.

1 Answers1

1

Is it possible for a non-authenticated user to be able to write/update documents (programmatically - via Google Drive API v2 or another API?) that have been created from the authenticated user that shared these? (something that is similar to google docs/ sharing when a user is sharing his document and offline users are able to edit it?

What you are describing here is something called a service account. Service accounts are like dummy users. You can share a file on your Google drive account with the service accounts email address and the service account will then have access to that file. Assuming that you gave them edit permissions it will be able to read and write to it without authenticating.

Note: service accounts do not work client sided you will need to use a server sided language to use service accounts.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • Thanks, I ran a small example and seems to work (I manually shared my documents on GDrive account with gserviceaccount and then get these documents through Java GoogleCredentials / DriveService etc & do some update action). I guess sharing programmatically is also possible? – spyDeveloper Apr 12 '18 at 14:52
  • When sharing a document with my new service account I am getting on my email (google author account) Delivery Status Notification (Failure) The response was: DNS Error: 18579231 DNS type 'mx' lookup of yyyyyyy.iam.gserviceaccount.com responded with code NXDOMAIN Domain name not found: yyyyyyy.iam.gserviceaccount.com Can I make any configurations to avoid sending email during sharing?? – spyDeveloper May 07 '18 at 11:18
  • 1
    Nope I am pritty sure its an automatic thing. – Linda Lawton - DaImTo May 07 '18 at 11:25