~> ipython
Python 3.9.5 (default, May 18 2021, 12:31:01)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.3.0 -- An enhanced Interactive Python. Type '?' for help.
[ins] In [1]: import requests
[ins] In [2]: api_key = open('.config/truenas/my_api_key.txt', 'r').read().strip()
[ins] In [3]: root_password = open('root_password.txt', 'r').read().strip()
[ins] In [4]: auth_dict = {"Content-Type": "application/json; charset=utf-8", "Authorization": f"Bearer {api_key}"}
[ins] In [5]: r = requests.get("
http://192.168.1.2/api/v2.0/rsyncmod", headers=auth_dict)
[ins] In [6]: r
Out[6]: <Response [401]>
[ins] In [7]: r = requests.get("
http://192.168.1.2/api/v2.0/rsyncmod", auth=("root", root_password))
[ins] In [8]: r
Out[8]: <Response [200]>