I am getting reviews from google business, i am using header Authorization Bearer, its frequently expired, again and again i am updating my Bearer token, how to handle this situation.
May i know the best practice for handling this situation?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this community$apiURL = "API URL";
$credentials = array("userName" => "username", "password" => "password");
$json_credentials = json_encode($credentials);
$ch = curl_init($apiURL);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_credentials);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($json_credentials)));
$token = curl_exec($ch);
$token = json_decode($token);
echo $token->token;
//Close handle
curl_close($ch);