I am trying to generate JWT token for apple connect API (to get sales report) in php.
i tried this format (using firebase/php-jwt)
$Private_key = file_get_contents('AuthKey_XYZ.p8');
$Issuer_ID = 'XYZ';
$Key_ID = 'ZDJ';
$data = [
'iss' => $Issuer_ID,
'iat' => \Carbon\Carbon::now()->timestamp,
'exp' => \Carbon\Carbon::now()->addMinutes(20)->timestamp,
'aud' => "appstoreconnect-v1"
];
$jwt = JWT::encode($data, $Private_key,'HS256', $Key_ID);
And receiving 401, did i missed something or the format is
I'm pretty sure the JWT encryption algorithm you are specifying is wrong. Try setting it to 'ES256', e.g:
$jwt = JWT::encode($data, $Private_key,'ES256', $Key_ID);from the docs under "Create the JWT header" https://developer.apple.com/documentation/appstoreconnectapi/generating_tokens_for_api_requests