Search code examples
python-3.xgoogle-drive-apigoogle-docsgoogle-docs-apigoogle-api-python-client

document creation using google APIs in python


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.


Solution

  • 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.