I’ve written beneath code for extending subscription renewal date. Going through “unauthenticated error” :-
$request = json_encode(
array(
"password"=>$applesharedsecret,
"extendByDays" => 7, // Required. The variety of days to increase the subscription renewal date max: 90 days
"extendReasonCode" => "Cause", // Required. The rationale code for the subscription date extension.
"requestIdentifier" => "$user_id" // Required. A string that incorporates a price you present to uniquely establish this renewal-date extension request.
)
) ;
$appleurl = "https://api.storekit-sandbox.itunes.apple.com/inApps/v1/subscriptions/prolong/$originalTransactionId"; // for manufacturing
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $appleurl);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cache-Management: no-cache"));
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$encodedResponse = curl_exec($ch); //Encoded apple response