question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

oauth2 error '_module' dict entry

See original GitHub issue

Hi,

I am trying to get the python quickstart.py to work described here: https://developers.google.com/drive/api/v3/quickstart/python

I also ran into #12, but additionally I am having issues loading the credentials.json that I downloaded when I enabled the Drive API per the link above.

It appears that the oauth2client module is attempting to extract a ‘_module’ entry, which doesn’t exist in the credentials.json file generated during the download.

I’ve been using python for a while, but this is the first time in a couple of years I’m playing with the google APIs. Not sure if this is something I’m doing wrong or if I stumbled on a bug.

ipython dump below. I confirmed that the data is a dict with the contents of the credentials.json file.

[edit: Note that I moved the credentials.json file into the same directory as the quickstart.py directory.]

Thanks,

  • Josh.
(C:\Users\josh\Anaconda3\envs\py35) d:\somedir>ipython --pdb quickstart.py
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
d:\somedir\quickstart.py in <module>()
     15 #store = file.Storage('PublishPdf.json')
     16 store = file.Storage('credentials.json')
---> 17 creds = store.get()
     18 if not creds or creds.invalid:
     19     flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)

C:\Users\josh\Anaconda3\envs\py35\lib\site-packages\oauth2client\client.py in get(self)
    405         self.acquire_lock()
    406         try:
--> 407             return self.locked_get()
    408         finally:
    409             self.release_lock()

C:\Users\josh\Anaconda3\envs\py35\lib\site-packages\oauth2client\file.py in locked_get(self)
     52
     53         try:
---> 54             credentials = client.Credentials.new_from_json(content)
     55             credentials.set_store(self)
     56         except ValueError:

C:\Users\josh\Anaconda3\envs\py35\lib\site-packages\oauth2client\client.py in new_from_json(cls, json_data)
    300         # Find and call the right classmethod from_json() to restore
    301         # the object.
--> 302         module_name = data['_module']
    303         try:
    304             module_obj = __import__(module_name)

KeyError: '_module'
> c:\users\josh\anaconda3\envs\py35\lib\site-packages\oauth2client\client.py(302)new_from_json()
    300         # Find and call the right classmethod from_json() to restore
    301         # the object.
--> 302         module_name = data['_module']
    303         try:
    304             module_obj = __import__(module_name)

ipdb>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:8

github_iconTop GitHub Comments

2reactions
Saledddarcommented, Jul 9, 2018

Same issue here

1reaction
baz1commented, Jul 15, 2018

“I am having issues loading the credentials.json that I downloaded” As the tutorial says, you should rename that file that you downloaded to “client_secret.json”. “credentials.json” will be automatically created when you run the Python script for the first time. (agreed that this might be confusing)

Read more comments on GitHub >

github_iconTop Results From Across the Web

oauth2 error '_module' dict entry · Issue #13 - GitHub
It appears that the oauth2client module is attempting to extract a '_module' entry, which doesn't exist in the credentials.json file ...
Read more >
python-oauth2 Documentation
This class defines the basic interface of each Grant. class oauth2.grant.ScopeGrant(default_scope=None, scopes=None, scope_class=<class.
Read more >
Getting a Python error (AttributeError: 'dict' object has no ...
The code I have to work with is obsolete as it was not meant for oauth2. I have received advice on how to...
Read more >
OAuth 2.0 identity provider API - GitLab Docs
Authorization code with Proof Key for Code Exchange (PKCE). The PKCE RFC includes a detailed flow description, from authorization request through access token....
Read more >
oauth2client Documentation - Read the Docs
Error when no Developer Shell server can be contacted. oauth2client.contrib.dictionary_storage module. Dictionary storage for OAuth2 Credentials ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found