891b9d01ae
EspoCRM uses TWO different auth schemes: * X-Api-Key: <apiKey> — for API-type users (no password) * Espo-Authorization: base64(u:p) — for regular users with passwords The PRD-derived constructor only set Espo-Authorization with a fake base64(username:apiKey) which the server rejects with 401 for API users. Fix: - Always send X-Api-Key when an apiKey is provided. - Also send Espo-Authorization Basic-style header when a username is supplied, so regular-user credentials still work without code changes. - Username is now optional (constructor + Settings dialog). API key is sufficient on its own; Settings credential store falls back to "(api-key)" as the recorded username for logging when blank. Tests updated: - FileMailAsync_AddsBothApiKeyAndBasicAuthHeaders — asserts X-Api-Key is the primary header and Espo-Authorization remains the fallback. - Constructor_RejectsBlankCredentials — empty username now allowed, empty apiKey / baseUrl still throw. All 38 tests green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>