Fix taa_client

This commit is contained in:
Nirvana
2025-11-15 12:58:31 +01:00
parent f92768c997
commit 85c82bc5b1
2 changed files with 44 additions and 16 deletions
@@ -16,31 +16,46 @@ MAGENTA2_PLATFORMS = {
'device_name': 'Web Browser',
'firmware': 'Chrome 120',
'user_agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'terminal_type': 'WEB'
'terminal_type': 'WEB',
# TAA-specific device identification
'taa_device_model': 'Web Browser',
'taa_os': 'Chrome 120'
},
'android-tv': {
'device_name': 'Android TV',
'firmware': 'Android 11',
'user_agent': 'Mozilla/5.0 (Linux; Android 11; Android TV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
'terminal_type': 'ATV_ANDROIDTV'
'terminal_type': 'ATV_ANDROIDTV',
# TAA-specific device identification (API level format required)
'taa_device_model': 'SHIELD Android TV',
'taa_os': 'API level 30'
},
'atv-launcher': {
'device_name': 'MagentaTV Stick',
'firmware': 'Android 11',
'user_agent': 'Mozilla/5.0 (Linux; Android 11; AFTS Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
'terminal_type': 'ATV_LAUNCHER'
'terminal_type': 'ATV_LAUNCHER',
# TAA-specific device identification
'taa_device_model': 'MagentaTV Stick',
'taa_os': 'API level 30'
},
'android-mobile': {
'device_name': 'Android Mobile',
'firmware': 'Android 13',
'user_agent': 'Mozilla/5.0 (Linux; Android 13; SM-G991B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Mobile Safari/537.36',
'terminal_type': 'ANDROID_MOBILE'
'terminal_type': 'ANDROID_MOBILE',
# TAA-specific device identification
'taa_device_model': 'Android Mobile',
'taa_os': 'API level 33'
},
'ios': {
'device_name': 'iPhone',
'firmware': 'iOS 15',
'user_agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1',
'terminal_type': 'IOS'
'terminal_type': 'IOS',
# TAA-specific device identification
'taa_device_model': 'iPhone',
'taa_os': 'iOS 15.0'
}
}
@@ -52,7 +52,7 @@ class TaaClient:
sam3_token: SAM3 access token for TAA scope
device_id: Device identifier
client_model: Client model from bootstrap
device_model: Device model from bootstrap
device_model: Device model from bootstrap (if None, uses taa_device_model from platform config)
taa_endpoint: TAA endpoint URL
Returns:
@@ -116,11 +116,11 @@ class TaaClient:
client_model: Optional[str] = None,
device_model: Optional[str] = None) -> Dict[str, Any]:
"""
Build complete TAA payload matching C++ structure exactly
Build complete TAA payload matching the correct format exactly
C++ structure:
Correct format:
{
"keyValue": "IDM/APPVERSION2/TokenChannelParams(id=Tv)/TokenDeviceParams(id=...,model=...,os=...)/DE/telekom",
"keyValue": "IDM/APPVERSION2/TokenChannelParams(id=Tv)/TokenDeviceParams(id=..., model=..., os=...)/DE/telekom",
"accessToken": "...",
"accessTokenSource": "IDM",
"appVersion": "APPVERSION2",
@@ -129,24 +129,35 @@ class TaaClient:
"natco": "DE",
"type": "telekom"
}
CRITICAL: Note the spaces after commas in TokenDeviceParams!
"""
# Use provided models or fallback to platform defaults
resolved_device_model = device_model or self.platform_config['device_name']
# Use provided device model or fallback to TAA-specific device model from platform config
# TAA requires specific device identification format (e.g., "SHIELD Android TV", "API level 30")
resolved_device_model = device_model or self.platform_config.get('taa_device_model') or self.platform_config[
'device_name']
# Get TAA-specific OS format (e.g., "API level 30" instead of "Android 11")
resolved_os = self.platform_config.get('taa_os') or self.platform_config['firmware']
resolved_client_model = client_model or f"ftv-{self.platform}"
# Build keyValue string matching C++ format exactly
# Build keyValue string with CORRECT spacing (spaces after commas!)
# Format: TokenDeviceParams(id=..., model=..., os=...)
# ^ ^
# spaces here!
key_value_parts = [
IDM,
APPVERSION2,
"TokenChannelParams(id=Tv)",
f"TokenDeviceParams(id={device_id},model={resolved_device_model},os={self.platform_config['firmware']})",
f"TokenDeviceParams(id={device_id}, model={resolved_device_model}, os={resolved_os})",
"DE",
"telekom"
]
key_value = "/".join(key_value_parts)
# Build complete payload matching C++ structure
# Build complete payload
payload = {
"keyValue": key_value,
"accessToken": sam3_token,
@@ -158,7 +169,7 @@ class TaaClient:
"device": {
"id": device_id,
"model": resolved_device_model,
"os": self.platform_config['firmware']
"os": resolved_os
},
"natco": "DE",
"type": "telekom"
@@ -169,6 +180,7 @@ class TaaClient:
payload["client"] = {"model": resolved_client_model}
logger.debug(f"Built TAA payload with keyValue: {key_value}")
logger.debug(f"Device model: {resolved_device_model}, OS: {resolved_os}")
return payload
def _parse_taa_response(self, taa_data: Dict[str, Any]) -> TaaAuthResult:
@@ -213,7 +225,8 @@ class TaaClient:
return result
def _parse_taa_jwt_complete(self, jwt_token: str) -> Dict[str, Any]:
@staticmethod
def _parse_taa_jwt_complete(jwt_token: str) -> Dict[str, Any]:
"""
Complete JWT parsing extracting ALL required fields from TAA token
"""