ValueError: Client secrets must be for a web or installed app
The problem was that I was using the json generated under Service account keys Manage service accounts and not the one under OAuth 2.0 client IDs.
Follow this instructor for creating oauth client id. https://developers.google.com/workspace/guides/create-credentials#oauth-client-id
For anyone coming here because they would like to actually connect to the GCP calendar API via a service-account and not this Oauth2 client id, create the creds
object in the original example as follows:
from google.oauth2 import service_account
SCOPES = ['https://www.googleapis.com/auth/calendar.readonly']
SERVICE_ACCOUNT_FILE = '/path/to/service.json'
credentials = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=SCOPES)
Assuming the service-account is configured with the correct access, this will access the calendar without prompting user for confirmation.