I've been trying to setup a program that will access a Google Docs file, specifically it should generate PDFs from a template document that is hosted on a shared Drive. This would be easy if I just needed to do it manually with OAuth, however I need this to run for the business without human intervention. To do that, I gather I should use a service account.
The problem is that I can't seem to grant the required permissions to the service account. I can't find any option to add permissions for Google Drive/Docs files to the service account. When giving "Owner" permissions, the program using the service account credentials still throws a 403 "the caller does not have permission" error.
I believe I could give delegation permissions for the service account to impersonate anybody within the anisation, and then it could use that to access the files, but that seems like overkill. I just want to access documents in a specific Drive folder. Is there a better way to get the permissions I need?
I've been trying to setup a program that will access a Google Docs file, specifically it should generate PDFs from a template document that is hosted on a shared Drive. This would be easy if I just needed to do it manually with OAuth, however I need this to run for the business without human intervention. To do that, I gather I should use a service account.
The problem is that I can't seem to grant the required permissions to the service account. I can't find any option to add permissions for Google Drive/Docs files to the service account. When giving "Owner" permissions, the program using the service account credentials still throws a 403 "the caller does not have permission" error.
I believe I could give delegation permissions for the service account to impersonate anybody within the anisation, and then it could use that to access the files, but that seems like overkill. I just want to access documents in a specific Drive folder. Is there a better way to get the permissions I need?
Share Improve this question edited Mar 17 at 20:42 PatrickdC 2,6192 gold badges9 silver badges30 bronze badges asked Mar 17 at 17:27 Rainbow-Anthony LilicoRainbow-Anthony Lilico 1057 bronze badges 2 |1 Answer
Reset to default 0Found a reasonable solution for my specific use case thanks to @dazwilkin - I can share a document or folder with a service account through its email in the same way I would share with a human. Other use cases might require domain wide delegation.
{account}@{project}.iam.gserviceaccount
) with the document as if it were a human user. It will gain the permission that you assign to it when you do this. – DazWilkin Commented Mar 17 at 17:59