So, to be able to use Apple Store Connect API, you need to generate the JWT Token, you can use this script. First clone this repo firebase/php-jwt, then create a file with this following content:
php
<?php
require __DIR__ . '/vendor/autoload.php';
use Firebase\JWT\JWT;
$appleKey = <<<EOD
-----BEGIN PRIVATE KEY-----
XXX
-----END PRIVATE KEY-----
EOD;
$appleKeyId = '2X9R4HXF34';
$appleIssuerId = '57246542-96fe-1a63-e053-0824d011072a';
$payloadBody = [
'iss' => $appleIssuerId,
'aud' => 'appstoreconnect-v1',
'iat' => time(),
'exp' => (time() + (60 * 5)),
];
$payloadHeader = [
"kid" => $appleKeyId,
"typ" => "JWT"
];
$jwt = JWT::encode($payloadBody, $appleKey, 'ES256', $appleKeyId, $payloadHeader);
print_r($jwt);
Then simply call php name_file.php
. To test the token you can use:
bash
curl -v -H 'Authorization: Bearer JWT_HERE' "https://api.appstoreconnect.apple.com/v1/apps"
That's it!
Last update: 2025-01-13 05:24:30 UTC
(4 days ago)