# Use confd api with python

**URL:** <https://wazo-platform.discourse.group/t/use-confd-api-with-python/61>\
**Category:** Development: API/Events\
**Created:** [November 26, 2019, 3:39pm UTC](https://wazo-platform.discourse.group/t/use-confd-api-with-python/61 "2019-11-26T15:39:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![benasse](https://avatars.discourse-cdn.com/v4/letter/b/e68b1a/32.png) [@benasse](https://wazo-platform.discourse.group/u/benasse)\
**Post date:** [November 26, 2019, 3:39pm UTC](https://wazo-platform.discourse.group/t/use-confd-api-with-python/61/1 "2019-11-26T15:39:14Z")

</div>

Hello,

I try to use `wazo_provd_client` and `wazo-confd-client` but I find myself annoyed because I only have a self-signed certificate and the client has no option to skip the ssl verification.

Do you plan to add an option to bypass the ssl verification?

What are the other alternative?

---

<div class="post-metadata">

**Author:** ![quintana](https://yyz2.discourse-cdn.com/free1/user_avatar/wazo-platform.discourse.group/quintana/32/916_2.png) [@quintana](https://wazo-platform.discourse.group/u/quintana)\
**Post date:** [November 26, 2019, 7:02pm UTC](https://wazo-platform.discourse.group/t/use-confd-api-with-python/61/2 "2019-11-26T19:02:19Z")

</div>

Hello, there is option to do that. Set verify\_certificate to false.

---

<div class="post-metadata">

**Author:** ![benasse](https://avatars.discourse-cdn.com/v4/letter/b/e68b1a/32.png) [@benasse](https://wazo-platform.discourse.group/u/benasse)\
**Post date:** [November 26, 2019, 9:21pm UTC](https://wazo-platform.discourse.group/t/use-confd-api-with-python/61/3 "2019-11-26T21:21:31Z")

</div>

Indeed, I had missed that, thank you.

Now I’m blocking on confd authentication, an idea?

```
>>> from wazo_auth_client import Client
>>> c = Client('localhost', username='wazo-auth-cli', password='2gZ6e4Zy7k9yFiaI3rly', verify_certificate=False)
>>> token_data = c.token.new('wazo_user', expiration=3600, session_type='mobile')
True
>>> print(token_data['token'])
4edb8108-3950-4b6e-a8e5-4066dbbd753a
>>> from wazo_confd_client import Client
>>> c = Client('localhost', port=9486, https=True, token=token_data['token'],verify_certificate=False)
>>> users = c.users.list(search='be')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/wazo_confd_client/crud.py", line 71, in list
response = self.session.get(url, headers=headers, params=kwargs)
  File "/usr/lib/python2.7/dist-packages/wazo_confd_client/session.py", line 58, in get
self.check_response(response, check_response)
  File "/usr/lib/python2.7/dist-packages/wazo_confd_client/session.py", line 36, in check_response
response.raise_for_status()
  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: 4edb8108-3950-4b6e-a8e5-4066dbbd753a for url: https://localhost:9486/1.1/users?search=be&recurse=False
```

---

<div class="post-metadata">

**Author:** ![pcm](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@pcm](https://wazo-platform.discourse.group/u/pcm)\
**Post date:** [November 28, 2019, 2:33pm UTC](https://wazo-platform.discourse.group/t/use-confd-api-with-python/61/4 "2019-11-28T14:33:35Z")

</div>

The username/password that you have used are for the wazo-auth-cli tool. This user does not have the necessary permission to list confd users.

You can use a user with the administrator rights or create a new one with more limited permissions.

to create a user myuser with password foobar  
`wazo-auth-cli user create --password foobar myuser`

The add the admin policy to that user  
`wazo-auth-cli user add --policy wazo_default_admin_policy myuser`

That should get you started with the authentication.

For your search you will want to add the `tenant_uuid=<tenant_uuid>` or `recurse=True` otherwise you will list only users from the master tenant which contains only system related resources.

---

<div class="post-metadata">

**Author:** ![benasse](https://avatars.discourse-cdn.com/v4/letter/b/e68b1a/32.png) [@benasse](https://wazo-platform.discourse.group/u/benasse)\
**Post date:** [November 28, 2019, 4:04pm UTC](https://wazo-platform.discourse.group/t/use-confd-api-with-python/61/5 "2019-11-28T16:04:35Z")

</div>

I managed to make it work thank you !

```
# create user: run just once
wazo-auth-cli user create --password superpass test
wazo-auth-cli user add --policy wazo_default_admin_policy test

python

# create tocken
from wazo_auth_client import Client
c = Client('localhost', username='test', password='superpass', verify_certificate=False)
token_data = c.token.new('wazo_user', expiration=3600, session_type='mobile')
print(token_data['token'])

# list all user
from wazo_confd_client import Client
c = Client('localhost', port=9486, https=True, token=token_data['token'],verify_certificate=False)
users = c.users.list(recurse=True)
print(users)
```
