I am running the quickstart.py example code under Python Quickstart and I am getting the following error:
ValueError: Client secrets must be for a web or installed app.
I created a credentials.json
file with project owner rights.
The error occurs in the following piece of code:
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file('credentials.json', SCOPES)
creds = flow.run_local_server()
# Save the credentials for the next run
with open('token.pickle', 'wb') as token:
pickle.dump(creds, token)
I notice also that the token.pickle file is not being created. This is the error output:
File "updateSlidev01.py", line 51, in <module>
main()
File "updateSlidev01.py", line 31, in main
flow = InstalledAppFlow.from_client_secrets_file('credentials.json', SCOPES)
File "/Library/Python/2.7/site-packages/google_auth_oauthlib/flow.py", line 174, in from_client_secrets_file
return cls.from_client_config(client_config, scopes=scopes, **kwargs)
File "/Library/Python/2.7/site-packages/google_auth_oauthlib/flow.py", line 147, in from_client_config
'Client secrets must be for a web or installed app.')
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.