This is my code
require __DIR__ . '/vendor/autoload.php';
use Firebase\JWT\JWT;
date_default_timezone_set("Asia/Taipei");
header('Content-Type: application/json'); // Specify the type of data
$privateKey =<<<eod
-----BEGIN PRIVATE KEY-----
my_private_here
-----END PRIVATE KEY-----
EOD;
$JWT_Header = array(
"kid"=> "my_kid",
);
$JWT_Payload = array(
"iss"=> "my_iss_id",
"exp"=>(string)time(),
"aud"=> "appstoreconnect-v1"
);
$jwt = JWT::encode($JWT_Header, $privateKey, 'ES256','YPVNQH3M54');
$authorization = "Authorization: Bearer ".$jwt;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.appstoreconnect.apple.com/v1/users");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//Set your auth headers
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Bearer ' . $authorization
));
$response = curl_exec($ch);
echo "";
$err = curl_error($ch);
curl_close($ch);
if ($err) {
echo "cURL Error #:" . $err."
";
print_r(json_decode($response));
} else {
print_r(json_decode($response));
}
function base64url_encode($data) {
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
I execute website display this message
<pre>stdClass Object |
( |
[errors] => Array |
( |
[0] => stdClass Object |
( |
[status] => 401 |
[code] => NOT_AUTHORIZED |
[title] => Authentication credentials are missing or invalid. |
[detail] => Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests https://developer.apple.com/go/?id=api-generating-tokens |
) |
) |
) |
Why am I fellow step by step still get above message ?