ValueError: Client secrets must be for a web or installed app ValueError: Client secrets must be for a web or installed app python python

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.


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_accountSCOPES = ['https://www.googleapis.com/auth/sqlservice.admin']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.


credentials should be a dictionary, not the path to the .json file.

I got this error message and from that, it was very difficult to figure out what went wrong. Turns out the credentials needed to be a dictionary and I was providing the path to the .json file(!).