Hi, I have the following code in order to add an new authorized address into Google Cloud SQL :
$access_token = "ya29.GltEBBtlPfCr1F-20oQq7GU-ZZWW9J7R9ftQc5II5oSnr7IKZGk2iMDN9CcRDG_njDzKctfD6g6N5HxOYk1wjRoSJSMyDevEqdlIxWFjId5ZOLnqfHnprWmtWK6Q";
$headers = array('Authorization: Bearer ' . $access_token, 'Content-Type: application/json');
$send_method = "PATCH";
$payload = '{"settings" : {"ipConfiguration" : {"authorizedNetworks" : [{ "value": "220.20.0.1" }]}}}';
$settings = array(
CURLOPT_CUSTOMREQUEST => $send_method,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_POSTFIELDS => $payload
);
$curl = curl_init($url);
curl_setopt_array($curl, ($settings));
$result = curl_exec($curl);
curl_close($curl);
I also know that the token is good because I got it from the oAuth playground.
I use a service account and I set myself as the owner of it.
Nevertheless, I get the following error (I also get it into the oAuth playground) :
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
What can I do?
Thanks!