python-samples: KeyError: '_module' error

I get the below error when running the script ::

PS C:\Users\nhr\Desktop\Gmail_Api> python quickstart.py Traceback (most recent call last): File “quickstart.py”, line 32, in <module> main() File “quickstart.py”, line 14, in main creds = store.get() File “C:\Python27\lib\site-packages\oauth2client\client.py”, line 407, in get return self.locked_get() File “C:\Python27\lib\site-packages\oauth2client\file.py”, line 54, in locked_get credentials = client.Credentials.new_from_json(content) File “C:\Python27\lib\site-packages\oauth2client\client.py”, line 302, in new_from_json module_name = data[‘_module’] KeyError: ‘_module’

Steps to Reproduce the Problem

I have followed the sames procedure described in https://developers.google.com/gmail/api/quickstart/python

  1. Install Python , PIP and all related modules
  2. Enabled GMAIL API and saved the credentials.json file in project directory
  3. Installed Google Client Library
  4. Copied and Saved the Quickstart.py file in project directory
  5. Run the python command to run quickstart.py

These are the files in my project directory:

09/25/2018 07:45 AM <DIR> . 09/25/2018 07:45 AM <DIR> … 09/25/2018 07:46 AM <DIR> .idea 09/09/2018 09:03 PM 431 client_secret.json 09/09/2018 08:42 PM 431 credentials.json 09/09/2018 08:33 PM 4,285 index.html 09/09/2018 08:40 PM 3,076 index.js 09/09/2018 08:56 PM 1,001 quickstart.py 09/09/2018 08:47 PM 340 token.json 6 File(s) 9,564 bytes

Specifications

  • Python version (python --version) : 2.7
  • OS (Mac/Linux/Windows) : Windows 10

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

What and in which format the token.json file should contain?

The file token.json is created after you authorize access to your account. This error indicates that the file exists, but isn’t in the expected format. What does your token.json file contain? Try renaming it to something else and running the quickstart again.