Skip to content

Repository files navigation

netauth-python

A NetAuth client library for Python.

Installation

pip install netauth

Usage

netauth-python centers around the NetAuth object:

na=netauth.NetAuth("netauth.example.org")
try:
resp=na.system_status()
print(resp)
exceptnetauth.error.NetAuthRpcErrorase:
print(f"Request failed: {e}")
na.close()

NetAuth can also be used as a context manager and be initialized from a NetAuth configuration file:

withnetauth.NetAuth.with_config(Path("/etc/netauth/config.toml")) asna:
try:
resp=na.system_status()
print(resp)
exceptnetauth.error.NetAuthRpcErrorase:
print(f"Request failed: {e}")

For interactive or dynamic applications, operations that require authentication can use a callback to retrieve the user's secret:

defsecret_cb() ->str:
returngetpass(prompt="Secret: ")
withnetauth.NetAuth("netauth.example.org", entity="demo", secret=secret_cb) asna:
try:
na.entity_kv_add("demo", "foo", ["bar", "baz"])
excepterror.NetAuthRpcErrorase:
print(e)

For more information, see the API documentation.

About

NetAuth client library for Python

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages