Authentication
Using an API key
The recommended approach for server-side applications:
from nuroute import NuRouteClient
client = NuRouteClient(
api_key="aicp-...",
base_url="https://your-gateway",
)
Create API keys in the dashboard under Settings → API Keys. An API key has no role, so changing settings (routing,
projects, providers) and managing API keys and members need an owner's or admin's session token from
client.auth.login() instead; with an API key those calls are refused with 403. A session token expires after 1 hour.
Signing up
result = client.auth.signup(
org_name="Acme Corp",
email="you@acme.com",
password="super-secret",
user_name="Your Name", # optional
)
# result["token"] is a session JWT
client.set_api_key(result["token"])
Logging in
result = client.auth.login(
email="you@acme.com",
password="super-secret",
)
client.set_api_key(result["token"])
Accepting an invitation
# Inspect the invite link token
info = client.auth.get_invite_info(token)
print(info["email"], info["org_name"])
# Accept and get a session
result = client.auth.accept_invite(
token=token,
name="New Member",
password="my-password",
)
client.set_api_key(result["token"])
Updating the API key at runtime
client.set_api_key("new-aicp-key-or-jwt")