Is is possible to give google service-account's access to whole drive instead of just folders?
I'm unable to switch to a new directory using google docs API in python. It was possible to jump into a folder and then create the document there using google drive APIs but I want to use docs API only and I can't see any way to jump into another folder.
1 Answer
Is is possible to give google service-account's access to whole drive instead of just folders?
If you have a Workspace domain, I'd suggest granting domain-wide authority to the service account in order to impersonate the regular user's My Drive and access everything they can access. See Delegating domain-wide authority to the service account for more details about how to accomplish this.
If this is not an option for you, you should share all top-level items on the Drive, since there's no direct method to share the full My Drive.
It was possible to jump into a folder and then create the document there using google drive APIs but I want to use docs API only and I can't see any way to jump into another folder.
You need to use Drive API to move files between folders. Docs API cannot be used for that.
Sidenote:
Not sure if you're aware of this, but please notice that, if you create a document via Docs API, you can only create a blank document, since all fields apart from title are ignored in this method (see documents.create). If you want to add text, change other properties, etc., you'll have to use documents.batchUpdate.
I'm mentioning this since I don't know whether that was the reason you wanted to create the document via Docs API.
6 Comments
documents.create method since I can't give service account access to whole My Drive using Google doc API. So currently I create a document manually in drive then give it service account access and then use its documentId to insert data in this document. But I don't want to do this, I want to create the doc using API and give it google account access. Also my account is not a Workspace domain.documents.batchUpdate won't work in drive APIs.documents.batchUpdate to update your file accordingly developers.google.com/docs/api/reference/rest/v1/documents/….
jump into another folderyou mean moving a file to a different folder? You cannot do this in Docs API, you have to use Drive API for this. May I know why you don't want to use Drive, and just Docs?result = service.documents().batchUpdate(documentId=DOCUMENT_ID, body={'requests': requests}).execute()batchUpdateis to be used with Docs API. But for file creation, I'd suggest using Drive API, since you want to add it to a specific folder. Take a look at my answer for more information.