https://github.com/netauth/netauth-python
NetAuth client library for Python
https://github.com/netauth/netauth-python
authentication-service netauth python secure-access
Last synced: 5 months ago
JSON representation
NetAuth client library for Python
- Host: GitHub
- URL: https://github.com/netauth/netauth-python
- Owner: netauth
- License: mit
- Created: 2024-07-31T00:46:12.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-07T05:11:33.000Z (almost 2 years ago)
- Last Synced: 2025-12-15T07:37:35.872Z (6 months ago)
- Topics: authentication-service, netauth, python, secure-access
- Language: Python
- Homepage: https://python.netauth.org
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## netauth-python
A [NetAuth](https://netauth.org) client library for Python.
### Installation
```
pip install netauth
```
### Usage
netauth-python centers around the `NetAuth` object:
```py
na = netauth.NetAuth("netauth.example.org")
try:
resp = na.system_status()
print(resp)
except netauth.error.NetAuthRpcError as e:
print(f"Request failed: {e}")
na.close()
```
`NetAuth` can also be used as a context manager and be initialized from a NetAuth configuration file:
```py
with netauth.NetAuth.with_config(Path("/etc/netauth/config.toml")) as na:
try:
resp = na.system_status()
print(resp)
except netauth.error.NetAuthRpcError as e:
print(f"Request failed: {e}")
```
For interactive or dynamic applications, operations that require authentication can use a callback to retrieve the user's secret:
```py
def secret_cb() -> str:
return getpass(prompt="Secret: ")
with netauth.NetAuth("netauth.example.org", entity="demo", secret=secret_cb) as na:
try:
na.entity_kv_add("demo", "foo", ["bar", "baz"])
except error.NetAuthRpcError as e:
print(e)
```
For more information, see the [API documentation](https://python.netauth.org).