0

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?

0

Token always expires in 24 hours So you need to get token programmatically using below curl code

$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);
1
  • $credentials = array("userName" => "username", "password" => "password"); --> my gmail account credientials?
    – zus
    May 1 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.