Skip to content

Commit cef9f33

Browse files
NohamRwrobelda
authored andcommitted
Use hardcoded JWT token in AppleAppStoreBridge (RSS-Bridge#4803)
* Use hardcoded JWT token in AppleAppStoreBridge Replaces the dynamic extraction of the JWT token from the page meta tag with a hardcoded token, as the previous method stopped working. The token is sourced from Apple's own JavaScript and is valid until January 26, 2026. * Refactor AppleAppStoreBridge to simplify token handling Removed the getJWTToken() method and inlined the hardcoded JWT token directly into getAppData(). Updated HTTP headers for API requests to better mimic browser behavior and improve compatibility. * Split long JWT token string for readability * Fix long JWT token string concatenation style * Disable and re-enable PHPCS rule for token assignment * Update hardcoded Apple App Store token Replaced the hardcoded JWT token and its reference to the latest version from Apple's JavaScript source.
1 parent d3c36c8 commit cef9f33

File tree

1 file changed

+15
-28
lines changed

1 file changed

+15
-28
lines changed

bridges/AppleAppStoreBridge.php

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -114,44 +114,31 @@ private function getHtml()
114114
return getSimpleHTMLDOM($url);
115115
}
116116

117-
private function getJWTToken()
117+
private function getAppData()
118118
{
119-
$html = $this->getHtml();
120-
$meta = $html->find('meta[name="web-experience-app/config/environment"]', 0);
121-
122-
if (!$meta || !isset($meta->content)) {
123-
throw new \Exception('JWT token not found in page content');
124-
}
125-
126-
$decoded_content = urldecode($meta->content);
127-
$this->debugLog('Found meta tag content');
128-
129-
try {
130-
$decoded_json = Json::decode($decoded_content);
131-
} catch (\Exception $e) {
132-
throw new \Exception(sprintf('Failed to parse JSON from meta tag: %s', $e->getMessage()));
133-
}
119+
// Spoof a call to get the HTML first to mimic browser behavior
120+
$url = $this->makeHtmlUrl();
121+
$content = getContents($url);
134122

135-
if (!isset($decoded_json['MEDIA_API']['token'])) {
136-
throw new \Exception('Token field not found in JSON structure');
137-
}
123+
// The above method stopped working, using a hardcoded token for now, "exp": 1769466135 (~Jan 26 2026)
124+
// This token is hardcoded in Apple's own JavaScript source code: https://apps.apple.com/assets/index~BMeKnrDH8T.js
138125

139-
$token = $decoded_json['MEDIA_API']['token'];
140-
$this->debugLog('Successfully extracted JWT token');
141-
return $token;
142-
}
143-
144-
private function getAppData()
145-
{
146-
$token = $this->getJWTToken();
126+
// phpcs:disable Generic.Strings.UnnecessaryStringConcat.Found
127+
$token = 'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlU4UlRZVjVaRFMifQ.'
128+
. 'eyJpc3MiOiI3TktaMlZQNDhaIiwiaWF0IjoxNzYyOTkwMTA3LCJleHAiOjE3NzAyNDc3MDcsInJvb3RfaHR0cHNfb3JpZ2luIjpbImFwcGxlLmNvbSJdfQ.'
129+
. 'IrZxlIHsZBiBLZPw1UZYkyqwbPDPmzcj8U57M3w252i3A4TRzASKx2aGAoXJ0WtuNihmyyopREeVqpJlpjq0fw';
130+
// phpcs:enable Generic.Strings.UnnecessaryStringConcat.Found
147131

148132
$url = $this->makeJsonUrl();
149133
$this->debugLog(sprintf('Fetching data from API: %s', $url));
150134

151135
$headers = [
136+
'accept: */*',
152137
'Authorization: Bearer ' . $token,
138+
'cache-control: no-cache',
153139
'Origin: https://apps.apple.com',
154-
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
140+
'Referer: https://apps.apple.com/',
141+
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36w',
155142
];
156143

157144
$content = getContents($url, $headers);

0 commit comments

Comments
 (0)