Sitelet https://github.com/googleworkspace/python-samples/issues/211
Skip to content

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

Open

Description

@stephenboston

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]

Activity

  1. Nadesri commented on Jul 21, 2021

    @Nadesri

    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:

  2. YoelMonsalve commented on Jul 28, 2021

    @YoelMonsalve

    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.

  3. its-all-waves commented on Nov 6, 2022

    @its-all-waves

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions