This is a simple proof of concept to read a Google Docs document using the Google Docs API.
-
Create a new project in the Google Cloud Console.
-
Enable the Google Docs API for the project. (Click here to see how to enable an API in GCP)
-
Create a new service account for the project. (No need to configure any roles since google apps (docs, sheets, etc) are not supported by the IAM system.)
-
Download the service account credentials as a JSON file.
-
Share the Google Docs document with the service account email address. (The service account email address can be found in the JSON file.)
- Set the GCP environment variables.
cp .env.example .env-
Fill in the
.envfile with the service account credentials. -
Run the script.
bun i
bun run index.ts