[英]JWT token generation for apple api in php
I am trying to generate JWT token for apple connect API (to get sales report) in php.我正在尝试在 php 中为苹果连接 API(以获取销售报告)生成 JWT 令牌。
i tried this format (using firebase/php-jwt)我试过这种格式(使用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并收到 401,我是否错过了什么或格式是
I'm pretty sure the JWT encryption algorithm you are specifying is wrong.我很确定您指定的 JWT 加密算法是错误的。 Try setting it to 'ES256', eg: $jwt = JWT::encode($data, $Private_key,'ES256', $Key_ID);
尝试将其设置为 'ES256',例如: $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来自“创建 JWT 标头”下的文档https://developer.apple.com/documentation/appstoreconnectapi/generating_tokens_for_api_requests
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.