i'm trying to get data from a firebase db, but as it's my first time using it i'm kind of stuck. This is the code i'm using:
$url = 'https://PROJECT_ID.firebaseio.com/runs/upcoming.json';
$token ='SERVER_KEY_TOKEN';
$headers = array(
'Content-Type:application/json',
'Authorization: Bearer '.$token
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . "?access_token=" . $token);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
but the response i'm getting is "error" : "Unauthorized request." . I see in the docs that I have to add scope https://www.googleapis.com/auth/userinfo.email but I have no idea how as I've tried several ways with no avail. Any help would be greatly appreciated.
I've tried also using the legacy server key and "auth=$token" but it did not work as well, but getting "Could not parse auth token" even with urlencode()