Implement error serialization.
Fix credentials expiry serialization.