Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client_secret.json vs client_secrets.json #506

Closed
charlesreid1 opened this issue May 18, 2018 · 2 comments
Closed

client_secret.json vs client_secrets.json #506

charlesreid1 opened this issue May 18, 2018 · 2 comments
Assignees

Comments

@charlesreid1
Copy link
Contributor

@charlesreid1 charlesreid1 commented May 18, 2018

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?

@mattwhisenhunt
Copy link
Contributor

@mattwhisenhunt mattwhisenhunt commented 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
Copy link
Contributor Author

@charlesreid1 charlesreid1 commented May 18, 2018

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.

yoshi-automation added a commit that referenced this issue May 29, 2020
These templates will be used for templates in python-docs-samples
and in Python client libraries. The README generation code is a modified
version of
https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/scripts/readme-gen.

Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>

Source-Author: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
Source-Date: Thu May 28 14:39:58 2020 -0700
Source-Repo: googleapis/synthtool
Source-Sha: ffe10407ee2f261c799fb0d01bf32a8abc67ed1e
Source-Link: googleapis/synthtool@ffe1040
busunkim96 pushed a commit that referenced this issue May 29, 2020
These templates will be used for templates in python-docs-samples
and in Python client libraries. The README generation code is a modified
version of
https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/scripts/readme-gen.

Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>

Source-Author: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
Source-Date: Thu May 28 14:39:58 2020 -0700
Source-Repo: googleapis/synthtool
Source-Sha: ffe10407ee2f261c799fb0d01bf32a8abc67ed1e
Source-Link: googleapis/synthtool@ffe1040
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants