auth.py: Add `write` function and new error class.