AttributeError: 'dict' object has no attribute 'json' on userpass.py
See original GitHub issueHello everyone,
I’m trying this library, and I have to admit that I’m pretty new to it, so maybe I’m doing something wrong.
I want to authenticate to a Vault server using Userpass method.
I created a client without problems, the vault is already unsealed, but I get an error like this:
>>> client = hvac.Client(url='MY_SERVER')
>>> client.sys.is_sealed()
False
>>> login_response = client.auth.userpass.login(
... username="MY_USERNAME",
... password="MY_PASSWORD"
... )
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-19-186fe49f4016> in <module>
----> 1 client.auth.userpass.login(username=username, password=password)
~/.virtualenvs/vualt/lib/python3.6/site-packages/hvac/api/auth_methods/userpass.py in login(self, username, password, mount_point)
138 json=params,
139 )
--> 140 return response.json()
AttributeError: 'dict' object has no attribute 'json'
Inspecting the file userpass.py
, I found that some methods are returned like response.json()
, and others returned like self._adapter.post( ... )
. I checked other files and most of the returns are like the second one.
Deleting the .json()
seems to work.
Is a problem in the library or from by side?
Cheers!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
'dict' object has no attribute 'read' - Stack Overflow
Since you want to convert it into json format, you should use json.dumps() instead of json.load() . This would work: >>> import json...
Read more >AttributeError: 'dict' object has no attribute 'read' | bobbyhadz
The "AttributeError: 'dict' object has no attribute 'read'" occurs when we try to access the read attribute on a dictionary, e.g. by passing...
Read more >'dict' object has no attribute 'write' : r/learnpython - Reddit
Using this code i got this error: 'dict' object has no attribute 'write' Code: users = {} data = [json.dumps(users)] data.append({nickname: ...
Read more >Python3: AttributeError: 'dict' object has no attribute 'itervalues'
Plugin fails in Python3: Traceback (most recent call last): File "trac\web\main.py", line 617, in dispatch_request dispatcher.dispatch(req) File ...
Read more >Ansible dict object has no attribute stdout (or) stderr
Generally, we display the stdout (or) stderr of the task at runtime by calling the corresponding task's register within the debug module and ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Howdy @checor! This looks like a bug introduced in the v0.10.1. I’ll try to get a fix merged in and released over the next few days.
In the meantime, I believe downgrading to v0.10.0 should allow you to work around the issue for now.
Ah yeah that makes sense and I had neglected considering having to support both variations. In general, the
adapter
attribute is not intended to for use by callers external to the module (this is obviously somewhat implicit unfortunately as the attribute is not marked as “private” here). Migrating to the more high-levelclient.write()
method should allow you to avoid that sort of logic I believe.