connectYouTube method
Connect to YouTube using the enhanced native SDK service
Implementation
Future<bool> connectYouTube(BuildContext context, [String? customClientId]) async {
try {
final username = await getFromSecure('username') ?? 'default_user';
debugPrint('🎬 Connecting to YouTube for user: $username');
// Check if we have a valid client ID
if (customClientId == null || customClientId.isEmpty ||
customClientId == '1030678346906-lovkuds2ouqmoc8eu5qpo98spa6edv4o.apps.googleusercontent.com') {
debugPrint('⚠️ YouTube integration unavailable - no custom client ID provided');
_showYouTubeUnavailableMessage(context);
return false;
}
// Use the new YouTube Connection Service for native SDK support
final youtubeService = YouTubeConnectionService();
final success = await youtubeService.signInWithGoogle(username, context, customClientId);
if (success) {
debugPrint('✅ YouTube connection successful');
} else {
debugPrint('❌ YouTube connection failed');
}
return success;
} catch (e) {
debugPrint('❌ Error connecting to YouTube: $e');
return false;
}
}