Hello there, I've another question about signing with apple more precisely how to create the jw token in php after sign with apple, here is what I do:
$header = json_encode(array(
'kid' => $keyId,
));
$decodedTokenData = json_decode(base64_decode(str_replace('_', '/', str_replace('-','+',explode('.', $_POST['id_token'])[1]))),true);
$payload = json_encode(array(
'iss' => $teamid,
'iat' => time(),
'exp' => time() + 86400*180,
'aud' => $decodedTokenData['aud'],
'sub' => $decodedTokenData['sub'],
));
$base64UrlHeader = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($header));
$base64UrlPayload = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($payload));
$signature = hash_hmac('sha256', $base64UrlHeader . "." . $base64UrlPayload, 'abC123!', true);
$base64UrlSignature = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($signature));
$jwt = $base64UrlHeader . "." . $base64UrlPayload . "." . $base64UrlSignature;
curl -X POST https://appleid.apple.com/auth/token -d '{"client_id":$CLIENTID,"client_secret":$jwt,"code": $_POST['code'],"grant_type":"authorization_code","redirect_uri":$URL}'
and I've got a
{"error":"invalid_client"}
i don't know what is wrong
Thanks in advance for your help