9

I am trying to use the quickstart.py ( https://developers.google.com/gmail/api/quickstart/python ) as per Google's Gmail API using oauth2. I am getting the below error.

Traceback (most recent call last):
  File "quickstart.py", line 68, in <module>
    main()
  File "quickstart.py", line 54, in main
    credentials = get_credentials()
  File "quickstart.py", line 37, in get_credentials
    credentials = store.get()
  File "/usr/local/lib/python2.7/dist-packages/oauth2client/client.py", line 407, in get
        return self.locked_get()
      File "/usr/local/lib/python2.7/dist-packages/oauth2client/file.py", line 54, in locked_get
        credentials = client.Credentials.new_from_json(content)
      File "/usr/local/lib/python2.7/dist-packages/oauth2client/client.py", line 302, in new_from_json
        module_name = data['_module']
    KeyError: '_module'

2 Answers 2

7

Finally, I have figured it out. The client_secret.json file which is downloaded from Google API console should be placed in the same directory as the python quickstart.py file and not inside ~/.credentials directory. This fixes the issue.

1

For me it was that I thought storage.json is supposed to be some file containing something, but it is supposed to be just a file name where the Python script can save data. So as soon as I gave it a path to a non-existing file, it worked.

1
  • Such a helpful answer. You explained precisely how the mechanism works. This is very useful when there is difficult documentation around the web. Jul 19, 2020 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.