The Google API Console is home to a baffling array of 305 APIs (at time of writing), including Google Docs, Sheets, Drive, Calendar, Maps, Ads, Analytics, Youtube, and GCP offerings.
The setup and management of authentication is equally baffling. Below I will walk through a series of different ways to manage serverside authentication.
In the below code, I provide made up secret keys that reflect the approximate length of each value. As always, avoid committing your actual secret keys to plain text.
For each new API you want to start using, I recommend creating a new Project under the existing Organization & GSuite user.
There are two overarching auth structures used for server-to-server auth: Service Workers and OAuth2 Clients. Service Workers are faster to get started with, so let's walk through their setup first.
#1.3 - name and describe the service account. you can pick the prefix of the service account ID, which will be followed by a random string