Closed GoogleCodeExporter closed 9 years ago
I have same problem
Original comment by preobrag...@gmail.com
on 18 Nov 2012 at 2:49
I have a similar problem.
1. I added my client_id, client_secret, developer_key, redirect_url in the
example file i.e (google-api-php-client/examples/calendar/simple.php'
2. Allow Access screen was shown as oauth2 authentication. I got the access
token. I printed it using print_r($client->getAccessToken()).
$cal->calendarList->listCalendarList() doesn't return anything and the page is
left blank.
3. I further checked apache error logs and I found the error as
PHP Fatal error: Uncaught exception 'Google_ServiceException' with message
'Error calling GET
https://www.googleapis.com/calendar/v3/users/me/calendarList?key=AIzaSyBreOHQze0
4C8TRtlbA_HVbFwjENgG5mD8: (403) Access Not Configured' in
<web_root>/google-api-php-client/src/io/Google_REST.php:66\nStack trace:\n#0
<web_root>/google-api-php-client/src/io/Google_REST.php(36):
Google_REST::decodeHttpResponse(Object(Google_HttpRequest))\n#1
<web_root>/google-api-php-client/src/service/Google_ServiceResource.php(177):
Google_REST::execute(Object(Google_HttpRequest))\n#2
<web_root>/google-api-php-client/src/contrib/Google_CalendarService.php(154):
Google_ServiceResource->__call('list', Array)\n#3
<web_root>/google-api-php-client/examples/calendar/simple.php(34):
Google_CalendarListServiceResource->listCalendarList()\n#4 {main}\n thrown in
<web_root>/google-api-php-client/src/io/Google_REST.php on line 66
4. I tried same code in my drupal site and their it threw error as
Google_ServiceException: Error calling GET
https://www.googleapis.com/calendar/v3/users/me/calendarList?key=AIzaSyBreOHQze0
4C8TRtlbA_HVbFwjENgG5mD8: (401) Invalid Credentials in
Google_REST::decodeHttpResponse() (line 66 of
<drupal-root>/google-api-php-client/src/io/Google_REST.php).
Original comment by dalvisad...@gmail.com
on 10 Dec 2012 at 4:24
I got the problem solved. I just deleted my older key and generated a new key
and it worked fine. I think the key was deactivated for some reason.
Original comment by dalvisad...@gmail.com
on 15 Dec 2012 at 9:30
i have successfully fetch profile data using Devkey but when i trying to get
event data than error is occuring that developer key is not valid error is ,
Uncaught exception 'Google_ServiceException' with message 'Error calling GET
https://www.googleapis.com/calendar/v3/users/me/calendarList?key=AIzaSyDkpplrsbA
mGQIM3Yhj_Oay70gnMHXh_-k: (401) Invalid Credentials' in
on server
Original comment by vthink.d...@gmail.com
on 22 Jan 2013 at 6:53
I am not sure about this but think that you should generate new api key that
actually fixed my problem, also make sure that the allowed IPS have the server
ip or the api is accessible to all.
I faced similar problem and generating new key simply fixed the problem.
You need to configure these options at https://code.google.com/apis/console
Hth,
Sadashiv
Original comment by dalvisad...@gmail.com
on 22 Jan 2013 at 5:22
Hello dalvi,
Thanks for your response. But it did not worked for me.
Here is the link that i am working on ...
http://demo.vthinksolution.com/adserver/ad_stat.php
click connect >> email: vthink.dev3@gmail.com and pwd : vthink123
------------------here is my 1 page code....-------------------
<?php
//date_default_timezone_set('Asia/Kolkata');
//echo $updateddate = date("d-m-Y h:i:s");
if (!isset($_SESSION)) {
session_start();
}
if (!isset($_SESSION['Email'])) {
header("Location:index.php");
}
?>
<?php
include_once "header.php";
?>
<!-- Load all Google JS libraries -->
<script src="https://www.google.com/jsapi"></script>
<script src="js/gadash-1.0.js"></script>
<script src="https://apis.google.com/js/client.js?onload=gadashInit"></script>
<div id='contents' style="margin-top:30px; ">
<div class="clear"></div>
<h1 id='page_header'>Analytics</h1>
<div class='clear'></div>
<button id="authorize-button" style="visibility: hidden">Authorize Analytics</button>
<div class='clear'></div>
</head>
<body>
<div id="chart_div" style="width: 900px;"></div>
<?php
error_reporting(E_ALL);
//$client = new setUseObjects(true);
ini_set("display_errors", 1);
require_once 'includes/google_api/Google_Client.php';
require_once "includes/google_api/contrib/Google_AnalyticsService.php";
require_once "includes/google_api/contrib/Google_CalendarService.php";
define ("ClientID" , "149795026372-srgdo1j6kcqb4nlp1od4ubrts3ash7qe.apps.googleusercontent.com");
define ("DevKey" , "AIzaSyDyZek8xUfwBGXc5f_qWJeAHrsisi1U7iY");
define ("SecretCode" , "k5fAJZn62lDu7w_u87vGIxAN");
define ("RedirectURI", "http://demo.vthinksolution.com/adserver/ad_stat.php");
define ("Scope" , "https://www.googleapis.com/auth/analytics.readonly");
$client = new Google_Client();
$client->setClientId("149795026372-srgdo1j6kcqb4nlp1od4ubrts3ash7qe.apps.googleusercontent.com");
$client->setClientSecret('k5fAJZn62lDu7w_u87vGIxAN');
$client->setRedirectUri('http://demo.vthinksolution.com/adserver/ad_stat.php');
$client->setDeveloperKey('AIzaSyDyZek8xUfwBGXc5f_qWJeAHrsisi1U7iY');
$client->setScopes(array('https://www.googleapis.com/auth/analytics.readonly'));
$service = new Google_AnalyticsService($client);
$client->setUseObjects(true);
if (isset($_GET['code'])) {
$client->authenticate();
$_SESSION['token'] = $client->getAccessToken();
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
//header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
//header('Location:first.php');
}
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
if (!$client->getAccessToken()) {
$authUrl = $client->createAuthUrl();
print "<a class='login' href='$authUrl'>Connect Me!</a>";
}
else {
runMainDemo($service) ;
}
function getResults(&$analytics, $profileId) {
return $analytics->data_ga->get(
'ga:' . $profileId,
'2012-01-01',
'2012-12-12',
'ga:visits');
}
function printResults(&$results) {
if (count($results->getRows()) > 0) {
$profileName = $results->getProfileInfo()->getProfileName();
$rows = $results->getRows();
$visits = $rows[0][0];
//print "<p>First profile found: $profileName</p>";
print "<p>Total visits: $visits</p>";
} else {
print '<p>No results found.</p>';
}
}
function getFirstprofileId(&$analytics) {
$accounts = $analytics->management_accounts->listManagementAccounts();
if (count($accounts->getItems()) > 0) {
$items = $accounts->getItems();
$firstAccountId = $items[0]->getId();
$webproperties = $analytics->management_webproperties
->listManagementWebproperties($firstAccountId);
$info = $webproperties->items[0] ;
$UrlName= $info->name;
$Created= $info->created;
$Url = $info->websiteUrl;
$TheID = $info->id;
echo "UA: " . $TheID . "<br/>";
echo "Unique Name: " . $UrlName . "<br/>";
echo "Created At: " . date("d / M / Y", strtotime($Created)) . "<br/>";
echo "Related URL: " . $Url . "<br/>";
if (count($webproperties->getItems()) > 0) {
$items = $webproperties->getItems();
$firstWebpropertyId = $items[0]->getId();
echo "<pre>";
print_r($items);
echo "</pre>";
$profiles = $analytics->management_profiles
->listManagementProfiles($firstAccountId, $firstWebpropertyId);
echo "<pre>";
print_r($profiles);
echo "</pre>";
if (count($profiles->getItems()) > 0) {
$items = $profiles->getItems();
return $items[0]->getId();
} else {
throw new Exception('No profiles found for this user.');
}
} else {
throw new Exception('No webproperties found for this user.');
}
} else {
throw new Exception('No accounts found for this user.');
}
}
function runMainDemo(&$analytics) {
try {
// Step 2. Get the user's first profile ID.
$profileId = getFirstProfileId($analytics);
if (isset($profileId)) {
// Step 3. Query the Core Reporting API.
$results = getResults($analytics, $profileId);
// Step 4. Output the results.
printResults($results);
}
} catch (apiServiceException $e) {
// Error from the API.
print 'There was an API error : ' . $e->getCode() . ' : ' . $e->getMessage();
} catch (Exception $e) {
print 'There wan a general error : ' . $e->getMessage();
}
}
/* event list get*/
//$client->setUseObjects(true);
echo "1";
$cal = new Google_CalendarService($client);
//$calendarList = $cal->calendarList->listCalendarList();
//echo "second";
//print "<h1>Calendar List</h1><pre>" . print_r($calendarList, true) . "</pre>";
echo "<pre>";
//print_r($events->events); exit;
echo "2";
$eventsParam = array("orderBy"=> '00:00:00', "timeMin"=>date('d-m-Y') ,
"timeMax"=>date('d-m-Y'));
$even = $cal->events->listEvents('vthink.dev3@gmail.com', $eventsParam);
Original comment by vthink.d...@gmail.com
on 24 Jan 2013 at 7:52
Please reopen if you're still having this issue. Mostly these issues are around
configuration in the API console. In general, you may get faster support for
general API issues on stackoverflow.
Original comment by ianbar...@google.com
on 22 Mar 2013 at 4:13
Error calling GET https://www.googleapis.com/calendar/v3/users/me/calendarList:
(401) Login Required in Google_REST::decodeHttpResponse()
I am facing the same issue.
Checked by creating new key and project also..
No any solution works
Original comment by test.neh...@gmail.com
on 25 Sep 2013 at 10:50
i have this error too:
Fatal error: Uncaught exception 'Google_ServiceException' with message 'Error
calling GET
https://www.googleapis.com/calendar/v3/users/me/calendarList?key=AIzaSyCryyx0YLW
PkHL1HKNBjYt4FYcjvlbMnrY: (403) Access Not Configured. Please use Google
Developers Console to activate the API for your project.' in
/app/webroot/google-api-php-client/src/io/Google_REST.php:66 Stack trace: #0
/app/webroot/google-api-php-client/src/io/Google_REST.php(36):
Google_REST::decodeHttpResponse(Object(Google_HttpRequest)) #1
/app/webroot/google-api-php-client/src/service/Google_ServiceResource.php(186):
Google_REST::execute(Object(Google_HttpRequest)) #2
/app/webroot/google-api-php-client/src/contrib/Google_CalendarService.php(205):
Google_ServiceResource->__call('list', Array) #3 /app/webroot/simple.php(43):
Google_CalendarListServiceResource->listCalendarList() #4 {main} thrown in
/app/webroot/google-api-php-client/src/io/Google_REST.php on line 66
Any solution ?
Original comment by MedykRej...@gmail.com
on 18 Jan 2014 at 1:59
I have
Uncaught exception 'Google_ServiceException' with message 'Error calling POST
https://www.googleapis.com/calendar/v3/calendars/ ...... : (401) Login Required'
bad service
Original comment by vladimir...@gmail.com
on 21 Jan 2014 at 2:45
You guys need to issue refreshToken() using the original authenticated access
code that contains a refresh token.
// example
$google_client->refreshToken($token->refresh_token);
Original comment by archive_...@rankpop.com
on 4 Feb 2014 at 3:30
[deleted comment]
where to put this line ?
$google_client->refreshToken($token->refresh_token);
I had this problem while inserting event.
Original comment by phularip...@gmail.com
on 10 Feb 2014 at 6:25
Do not use the developerkey just use other.. It worked for me..
$client->setClientId('insert_your_oauth2_client_id');
$client->setClientSecret('insert_your_oauth2_client_secret');
$client->setRedirectUri('insert_your_oauth2_redirect_uri');
// $client->setDeveloperKey('insert_your_developer_key');
Original comment by sud.m...@gmail.com
on 16 Feb 2014 at 11:32
Yup, comment out 'setDeveloperKey' worked for me. Thank You!
Original comment by MarkR...@gmail.com
on 10 Aug 2014 at 2:31
Original issue reported on code.google.com by
webtest....@gmail.com
on 10 Nov 2012 at 5:31