halo_auth 0.0.2
halo_auth: ^0.0.2 copied to clipboard
A Flutter plugin for multi-platform authentication with support for Android, iOS, Windows, and Linux. Provides device-specific authentication flows including Android TV content provider integration, i [...]
halo_auth #
A Flutter plugin for multi-platform authentication with support for Android, iOS, Windows, and Linux. Provides device-specific authentication flows with clean architecture.
Features #
- ✅ Multi-Platform Support: Android, iOS, Windows, and Linux
- ✅ Platform-Specific Authentication:
- Android Mobile: Uses Android ID
- Android TV: Reads tokens from Content Provider
- iOS: MDM configuration support
- Windows: Registry-based device identification
- Linux: Environment file configuration
- ✅ Full Response Model: Returns complete login response with configuration data (config, refs, tenant, etc.) for non-TV devices
- ✅ TV Device Support: Simple token response for TV devices
- ✅ Clean Architecture: Domain, Data, and Presentation layers
- ✅ Automatic Retry Logic: Handles device enrollment with retry mechanisms
- ✅ Error Handling: Comprehensive error handling with user-friendly UI feedback
Supported Platforms #
- ✅ Android (Mobile & TV)
- ✅ iOS
- ✅ Windows
- ✅ Linux
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
halo_auth: ^0.0.2
Then run:
flutter pub get
Usage #
Basic Usage #
import 'package:halo_auth/halo_auth.dart';
final haloAuth = HaloAuth();
// Authenticate with baseUrl and optional context
final tokens = await haloAuth.authenticate(
'https://portal.qa.halofort.com',
context: context, // Optional: for showing UI dialogs
);
// Access basic tokens (available for all platforms)
print('Token: ${tokens.token}');
print('Refresh Token: ${tokens.refreshToken}');
print('Device ID: ${tokens.deviceId}');
print('Reporting Token: ${tokens.reportingToken}');
// Check device type
if (tokens.isTvDevice) {
// TV device - simple tokens only
print('TV Device - Simple tokens');
} else if (tokens.isFullResponse) {
// Non-TV device - full response with config
print('Full Response with Config');
// Access configuration data
final config = tokens.config;
if (config != null) {
print('App: ${config.app}');
print('Device: ${config.device}');
print('Environment: ${config.environment}');
print('Tenant: ${config.tenant}');
print('User: ${config.user}');
print('Group: ${config.group}');
print('Policy Code: ${config.policycode}');
// Access references (CERT_ID, SERIAL, UDID, etc.)
if (config.refs != null) {
for (final ref in config.refs!) {
print('${ref.type}: ${ref.value}');
}
}
}
// Access full login response
final loginResponse = tokens.loginResponse;
print('Status: ${loginResponse?.status}');
}
With Error Handling #
try {
final tokens = await haloAuth.authenticate(
'https://portal.qa.halofort.com',
context: context,
);
// Use tokens
setState(() {
_token = tokens.token;
_refreshToken = tokens.refreshToken;
_deviceId = tokens.deviceId;
_reportingToken = tokens.reportingToken;
});
// Access full response for non-TV devices
if (tokens.isFullResponse && tokens.config != null) {
setState(() {
_tenant = tokens.config!.tenant;
_environment = tokens.config!.environment;
_policyCode = tokens.config!.policycode;
});
}
} catch (e) {
// Handle authentication errors
print('Authentication failed: $e');
}
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
License #
[Add your license here]
Support #
For issues and feature requests, please use the GitHub issue tracker.