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

quickstart.py credentials.json not found for read #211

Open
stephenboston opened this issue Jul 11, 2021 · 3 comments
Open

quickstart.py credentials.json not found for read #211

stephenboston opened this issue Jul 11, 2021 · 3 comments

Comments

@stephenboston
Copy link

Expected Behavior

As described in https://developers.google.com/gmail/api/quickstart/python

Actual Behavior

File "/hd2/projects/temp/python-samples/gmail/quickstart/quickstart.py", line 62, in
main()
File "/hd2/projects/temp/python-samples/gmail/quickstart/quickstart.py", line 41, in main
flow = InstalledAppFlow.from_client_secrets_file(
File "/home/stephen/.local/lib/python3.9/site-packages/google_auth_oauthlib/flow.py", line 180, in from_client_secrets_file
with open(client_secrets_file, 'r') as json_file:
FileNotFoundError: [Errno 2] No such file or directory: 'credentials.json'

Steps to Reproduce the Problem

1.Download these python samples

  1. install requirements through requirements.txt
  2. run the script

Specifications

  • Python version (python --version)
  • 3.9.6
  • OS (Mac/Linux/Windows)
  • Arch rolling[5.10.48-1-lts]
@Nadesri
Copy link

Nadesri commented Jul 21, 2021

I had the same error but found I was just not reading carefully enough; based on your repro steps it's possible you ran into the same thing.

The README.md is a bit confusing about this, but you need to follow the Prerequisites in the Python Quickstart page first: https://developers.google.com/gmail/api/quickstart/python#prerequisites

Note the following requirements in particular:

@YoelMonsalve
Copy link

YoelMonsalve commented Jul 28, 2021

I had the same issue, and it's kind of silly (just had to read carefully). Create a credential for your desktop application (as it's based on Python) as described by Nadersi: https://developers.google.com/workspace/guides/create-credentials

Then, download the client secret JSON file: https://developers.google.com/workspace/guides/create-credentials#desktop

Note, when it says:

Click the download button to the right of the newly-created OAuth 2.0 Client ID. This copies a client secret JSON file to your desktop

This is the file they are referring as "credentials.json". Copy this client secret file to your proper location, rename it to "credentials.json" and of course, give it the read permissions.

@its-all-waves
Copy link

its-all-waves commented Nov 6, 2022

For anyone else having this issue who did follow the instructions to a T (except for one part)...

My issue was that I was trying to run quickstart.py from within VS Code (with venv active). Why can't this work? Hell if I know. But when ran the file in terminal --> python quickstart.py (after activating the same venv), it worked.

For the record, I did not have to change any permissions on the json file. It came with read permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants