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?

1 Answer 1

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
    Commented May 1, 2021 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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