Flutter authentication
Load short-lived app-user tokens from your backend without exposing an application credential.
Implement TokenProvider
import 'package:v_chat_flutter/v_chat_flutter.dart';
final class BackendTokenProvider implements TokenProvider {
const BackendTokenProvider();
@override
Future<AuthToken> getToken({required bool forceRefresh}) {
return loadCurrentUserVChatToken(forceRefresh: forceRefresh);
}
}Backend token endpoint
- Authenticate the product user with your normal backend session.
- Derive the V Chat user ID server-side from that identity.
- Use AppServerClient and the protected application credential to issue a bounded token.
- Return the opaque token and optional ISO expiry over HTTPS.
- Do not return refresh tokens or the application credential.
Logout and account switching
- Revoke the current device registration before logout when push is attached.
- Disconnect realtime and stop all listeners.
- Dispose the client and its owned offline store.
- Create a fresh SDK and scoped database for the next user; never reuse state across logical sessions.