Molca.Networking.AuthFile:
Packages/com.molca.core/Runtime/Networking/Auth/AuthManager.csInterface:
IAuthManagerType:
RuntimeSubsystem (child of RuntimeManager prefab)
When to use
UseAuthManager when your app needs user authentication with token-based session management. It handles login/logout, cached token validation on startup, and automatic auth header injection on outgoing HTTP requests via AuthTokenInterceptor.
Role
- Login —
LoginAsync(username, password)authenticates via a configuredHttpRequestAsset, persists the encrypted user data toSecureStorage. - Cached token validation —
TryValidateCachedToken()loads persisted credentials and validates against the server. - Auto-injection —
AuthTokenInterceptorautomatically adds the auth token header to every outgoingIHttpClientrequest. - Guest login —
GuestLogin(data)creates an unauthenticated session for anonymous users. - Logout —
LogoutAsync()clears local state and notifies the server.
Inspector configuration
API Reference
Code
Events
AuthManager dispatches typed events through EventDispatcher:
AuthEvents.LoggedIn— fired after successful login/guest login withAuthLoggedInEventDataAuthEvents.LoggedOut— fired after logout/clear withAuthLoggedOutEventData
Troubleshooting
TryValidateCachedTokenreturns false: the cached token has expired or the server endpoint is unreachable. User must log in again.- Auth header not sent on requests: ensure
authTokenKeymatches the header name the server expects. The interceptor fires automatically on requests built throughIHttpClient.
Related
- HttpClient — underlying transport; auth headers injected automatically
- IHttpRequestInterceptor —
AuthTokenInterceptorimplements this - SecureStorage — encrypted local credential persistence