Получаю код авторизации на Google API. Вставляю его в curl и пытаюсь получить таймзону. Отвечает: bad token. Подскажите: где косяк?
$url_settings = 'https://www.googleapis.com/calendar/v3/users/me/settings/timezone';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_settings);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer 4/jwEgFJuak3-Gp8ZjR9Bk3iyPgYGi3xwO3ADPzfDf13хххххххххsah2F_0kqV4FknIWbMAeYH1fl8nl_M8'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$data = json_decode(curl_exec($ch), true); echo '<pre>';print_r($data);echo '</pre>';
$http_code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
if($http_code != 200)
echo('Error : Failed to get timezone');
Заголовки
HTTP/1.1 401 Unauthorized Vary: X-Origin WWW-Authenticate: Bearer realm="https://accounts.google.com/", error=invalid_token Content-Type: application/json; charset=UTF-8 Date: Sat, 27 Jul 2019 09:35:46 GMT Expires: Sat, 27 Jul 2019 09:35:46 GMT Cache-Control: private, max-age=0 X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block Server: GSE Alt-Svc: quic=":443"; ma=2592000; v="46,43,39" Accept-Ranges: none Vary: Origin,Accept-Encoding Transfer-Encoding: chunked {"error": {"errors": [{"domain": "global","reason": "authError","message": "Invalid Credentials","locationType": "header","location": "Authorization"}],"code": 401,"message": "Invalid Credentials"} }