Problem Solved
I have successfully obtained an OAuth2 token with proper scopes for accessing Google Calendar Events and Google Contacts (-edit- with both APIs enabled on Google Developers console), using the php client library. I am able to access events with the client using the service however there is no service for contacts.
How can I manually send an authorized GET request to the Google Contacts API (GData-ver:3.0) with the OAuth2 token as referenced here?
This is in Joomla 3.x but I'm working directly with php.
$retrieveURL = 'https://www.google.com/m8/feeds/contacts/default/full?access_token=' . urlencode($tokens->access_token) . '&v=3.0';
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, $retrieveURL);
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cURL, CURLINFO_HEADER_OUT, 1);
curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, false);
$gContacts = curl_exec($cURL);
if ($errno = curl_errno($cURL)) {
$error_message = curl_strerror($errno);
echo("cURL error ({$errno}):\n {$error_message}:\n ");
var_dump(curl_getinfo($cURL, CURLINFO_HEADER_OUT));
}
var_dump($gContacts);
return $gContacts;
The response from Google:
401. That's an error. There was an error in your request. That's all we know.