You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed a lot of inconsistency in example code given in various API documentation (I have looked at Calendar API, Directory API, Sheets API, YouTube API, and Drive API. I'm API-ed out). All of it uses this library, but some are using client_secret.json and others are using client_secrets.json. This repo seems to use client_secrets.json consistently so I don't understand why client_secret.json (no s) is being introduced.
But it is being introduced: see e.g. this commit to the youtube api samples that changes client_secrets.json to client_secret.json. (Is this an official source of samples? a google person developing a side project? supported unofficially but officially? the chain of ownership here is left ambiguous and that's frustrating. their contributing document points to this repo.)
Meanwhile the calendar sample is hosted in this repo and uses client_secrets.json consistent with the rest of the repo.
In spite of all this, sometimes even the incorrectly-named file seems to work. What's going on here?
The name of the file is not important, its the content that counts. Depending on what language you are using and what environment your deploying to, you won't even have that json file.
https://github.com/youtube is an official source and it appears their api-samples repo is a helpful collection code samples to interact, specifically, with Youtube. I don't think those samples are limited to examples of this client library or its sister client libraries of other languages.
I am sorry you are feeling frustrated and I've tried to answer your questions. If you have more specific problems or some code that is not working I would be glad help.
Thanks for the explanation. Another cause of confusion was that the name of the json file is specified in sample_tools so it isn't clear where that comes from (or that it's arbitrary). The sample_tools import shows up in the samples like the calendar sample but is also used in some documentation examples.
Things started to click once I saw the Drive API example that explicitly goes through the whole process, where you specify yourself where the application's credentials live and where the Drive credentials will go. That made the 3-legged authentication process easier to see, and figure out why the Calendar API credentials were going in calendar.dat while Drive API credentials were going in credentials.json.
Just this bit was all I needed:
# Setup the Drive v3 API
SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'
store = file.Storage('credentials.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('drive', 'v3', http=creds.authorize(Http()))
Personally I don't think the sample_tools magic is necessary, just my 2 cents.
Activity
mattwhisenhunt commentedon May 18, 2018
The name of the file is not important, its the content that counts. Depending on what language you are using and what environment your deploying to, you won't even have that json file.
https://github.com/youtube is an official source and it appears their api-samples repo is a helpful collection code samples to interact, specifically, with Youtube. I don't think those samples are limited to examples of this client library or its sister client libraries of other languages.
Google owns all the code, everyone agrees to that before their contribution is accepted: https://cla.developers.google.com/about/google-individual
I am sorry you are feeling frustrated and I've tried to answer your questions. If you have more specific problems or some code that is not working I would be glad help.
charlesreid1 commentedon May 18, 2018
Thanks for the explanation. Another cause of confusion was that the name of the json file is specified in
sample_toolsso it isn't clear where that comes from (or that it's arbitrary). Thesample_toolsimport shows up in the samples like the calendar sample but is also used in some documentation examples.Things started to click once I saw the Drive API example that explicitly goes through the whole process, where you specify yourself where the application's credentials live and where the Drive credentials will go. That made the 3-legged authentication process easier to see, and figure out why the Calendar API credentials were going in
calendar.datwhile Drive API credentials were going incredentials.json.Just this bit was all I needed:
Personally I don't think the
sample_toolsmagic is necessary, just my 2 cents.feat: add templates for python samples projects (#506)
feat: add templates for python samples projects (#506) (#924)
chore: release 1.9.0 (#925)