SDKsPython SDKAuthentication
Register
Create new user accounts with the Python SDK.
Register
register()
def register(
self,
*,
email: str,
password: str,
traits: UserTraits | None = None,
organization_id: str | None = None,
) -> SessionBasic usage
from avnology_id import AvnologyId
from avnology_id.types import UserTraits, UserName
client = AvnologyId(
base_url="https://api.id.avnology.com",
client_id="app_abc123",
client_secret="sk_live_...",
)
session = client.register(
email="[email protected]",
password="SecurePassword123!",
traits=UserTraits(
name=UserName(first="Jane", last="Doe"),
phone="+15550100",
locale="en-US",
),
)
print(session.identity.email) # "[email protected]"Error handling
from avnology_id.errors import (
DuplicateAccountError,
PasswordBreachedError,
PasswordTooWeakError,
ValidationError,
)
try:
session = client.register(email=email, password=password, traits=traits)
except DuplicateAccountError:
print("An account with this email already exists")
except PasswordBreachedError:
print("This password was found in a data breach")
except PasswordTooWeakError as e:
print(f"Password too weak: {e.reason}")
except ValidationError as e:
for field_error in e.field_errors:
print(f"{field_error.field}: {field_error.message}")verify_email()
client.verify_email(code="482901")
# Check verification status
session = client.get_session()
print(session.identity.verified_at) # datetime or Noneresend_verification()
client.resend_verification(email="[email protected]")