I have a php app on my site that allows my users to schedule/reschedule calendar events using one of my google calendars, so I don't need the users to authenticate themselves with google. I have worked through getting a token and stored a refresh token but now when I try to access calendar I get an error that says my token has expired. The output is
creating a client
found access token = { "access_token" : "long...token...string", "token_type" : "Bearer", "expires_in" : 3600 }
An error occurred: (0) The OAuth 2.0 access token has expired, and a refresh token is not available. Refresh tokens are not returned for responses that were auto-approved.
Not sure why I'm getting this error.
function getAccessToken(){
$tokenURL = 'https://accounts.google.com/o/oauth2/token';
$postData = array(
'client_secret'=>'My-Secret',
'grant_type'=>'refresh_token',
'approval_promt'=> 'force',
'refresh_token'=>'My-Refresh-Token',
'client_id'=>'My-Client-ID'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $tokenURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$tokenReturn = curl_exec($ch);
return $tokenReturn;
}
function outputCalendarByDateRange($client, $startDate='2007-05-01', $endDate='2007-08-01'){
date_default_timezone_set("America/Chicago");
$client->addScope('https://www.googleapis.com/auth/calendar');
try {
$service = new Google_Service_Calendar($client);
}catch(Google_ServiceException $e){
print "Error code :" . $e->getCode() . "\n";
print "Error message: " . $e->getMessage() . "\n";
} catch (Google_Exception $e) {
print "An error occurred: (" . $e->getCode() . ") " . $e->getMessage() . "\n";
}
$optParams = array(
'orderBy'=>'starttime',
'singleEvents'=>False,
'timeMax'=>$endDate,
'timeMin'=>$startDate,
'timeZone'=>'America/Chicago',
'maxResults'=>1000
);
try{
$events = $service->events->listEvents('primary',$optParams);
} catch (Google_ServiceException $e) {
print "Error code :" . $e->getCode() . "\n";
print "Error message: " . $e->getMessage() . "\n";
} catch (Google_Exception $e) {
print "An error occurred: (" . $e->getCode() . ") " . $e->getMessage() . "\n";
}
foreach ($events->getItems() as $event) {
echo $event->getSummary();
}
}
echo "creating a client<br>";
$client = new Google_Client();
$accessToken = getAccessToken();
echo "found access token = ".$accessToken."<br>";
try{
$client->setAccessToken($accessToken);
}
catch (Google_ServiceException $e) {
print "Error code :" . $e->getCode() . "\n";
print "Error message: " . $e->getMessage() . "\n";
} catch (Google_Exception $e) {
print "An error occurred: (" . $e->getCode() . ") " . $e->getMessage() . "\n";
}
outputCalendarByDateRange($client, $today, $tomorrow);
You should consider doing this with a service account. A service account will allow your application to access your Google Calendar data without prompting a user for access.
When you create the service account take the email address it gives you and add it like you would any other user to your Google Calendar. The script will then have access to it.
<?php
session_start();
require_once 'Google/Client.php';
require_once 'Google/Service/Calendar.php';
/************************************************
The following 3 values an befound in the setting
for the application you created on Google
Developers console. Developers console.
The Key file should be placed in a location
that is not accessable from the web. outside of
web root.
In order to access your GA account you must
Add the Email address as a user at the
ACCOUNT Level in the GA admin.
************************************************/
$client_id = '1046123799103-nk421gjc2v8mlr2qnmmqaak04ntb1dbp.apps.googleusercontent.com';
$Email_address = '1046123799103-nk421gjc2v8mlr2qnmmqaak04ntb1dbp#developer.gserviceaccount.com';
$key_file_location = '629751513db09cd21a941399389f33e5abd633c9-privatekey.p12';
$client = new Google_Client();
$client->setApplicationName("Client_Library_Examples");
$key = file_get_contents($key_file_location);
// seproate additional scopes with a comma
$scopes ="https://www.googleapis.com/auth/calendar.readonly";
$cred = new Google_Auth_AssertionCredentials(
$Email_address,
array($scopes),
$key
);
$client->setAssertionCredentials($cred);
if($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion($cred);
}
$service = new Google_Service_Calendar($client);
?>
<html><body>
<?php
$calendarList = $service->calendarList->listCalendarList();
print_r($calendarList);
while(true) {
foreach ($calendarList->getItems() as $calendarListEntry) {
echo "<a href='Oauth2.php?type=event&id=".$calendarListEntry->id." '>".$calendarListEntry->getSummary()."</a><br>\n";
}
$pageToken = $calendarList->getNextPageToken();
if ($pageToken) {
$optParams = array('pageToken' => $pageToken);
$calendarList = $service->calendarList->listCalendarList($optParams);
} else {
break;
}
}
?>
</html>
Code ripped from tutorial Google Calendar API with PHP – Service Account
Related
Facebook login does not pass the session parameters during the first login mostly on chromium based browsers. However from the second login it works and it passes the session parameters. Due to this behaviour the images do not get displayed during the first login.
Please find below a screen recording of the issue.
https://drive.google.com/file/d/1hig44sBeRsQq0rgr7imjOcsblfmedUuh/view?usp=sharing
The code snippet of the implementation:
if(!session_id()) {
session_start();
}
require_once './Facebook/autoload.php';
$fb = new Facebook\Facebook([
'app_id' => '',
'app_secret' => '',
'default_graph_version' => 'v2.2',
]);
$_SESSION['FBRLH_state']=$_GET['state'];
$helper = $fb->getRedirectLoginHelper();
#$_SESSION['FBRLH_state']=$_GET['state'];
try {
$accessToken = $helper->getAccessToken();
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
print 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
print 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
if (! isset($accessToken)) {
if ($helper->getError()) {
header('HTTP/1.0 401 Unauthorized');
print "Error: " . $helper->getError() . "\n";
print "Error Code: " . $helper->getErrorCode() . "\n";
print "Error Reason: " . $helper->getErrorReason() . "\n";
print "Error Description: " . $helper->getErrorDescription() . "\n";
} else {
header('HTTP/1.0 400 Bad Request');
print 'Bad request';
}
exit;
}
// Logged in
print '<h3>Access Token</h3>';
var_dump($accessToken->getValue());
// The OAuth 2.0 client handler helps us manage access tokens
$oAuth2Client = $fb->getOAuth2Client();
// Get the access token metadata from /debug_token
$tokenMetadata = $oAuth2Client->debugToken($accessToken);
print '<h3>Metadata</h3>';
var_dump($tokenMetadata);
// Validation (these will throw FacebookSDKException s when they fail)
#$tokenMetadata->validateAppId('');
$tokenMetadata->validateAppId('');// Replace {app-id} with your app id
// If you know the user ID this access token belongs to, you can validate it here
//$tokenMetadata->validateUserId('123');
$tokenMetadata->validateExpiration();
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->get('/me?fields=id,name,email,gender,picture,timezone', $accessToken);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
print 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
print 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$user = $response->getGraphUser();
$user1 = $response->getGraphUser();
$user2 = $response->getGraphUser();
$user3 = $response->getGraphUser();
$user4 = $response->getGraphUser();
print 'Name: ' . $user['name'];
$user = $user['name'];
$_SESSION['name'] = $user;
print $user;
print 'Email: ' . $user1['email'];
$_SESSION['emailfb'] = $user1['email'];
#print 'Location: ' . $user2['location'];
#$_SESSION['location'] = $user2['location'];
print 'Picture: ' . $user3['picture'];
$_SESSION['picturefb'] = $user3['picture'];
//profile pic
print"profile picture";
print"<br>";
$fbp = $_SESSION['picturefb'];
print"<br>";
#print"id:";
print 'id: '. $user1['id'];
$_SESSION['idfb'] = $user1['id'];
$id = $_SESSION['idfb'];
#$_SESSION['fbid'] =
$imgurl = 'https://graph.facebook.com/'.$id.'/picture?width=720';
$_SESSION['imgurl'] = $imgurl;
print"$imgurl";
print"<br>";
print"<img src ='$imgurl'/>";
#print 'Timezone: ' . $user1['timezone'];
// $_SESSION["Gender"] = $user2['location'];
// if(empty($_SESSION["gender"]))
// {
// $_SESSION["Gender"] ="Details not public";
// }
// print $_SESSION["Gender"];
$_SESSION['loggedin'] = true;
$_SESSION['fbflag'] = 1;
$_SESSION['username'] = $user;
if (! $accessToken->isLongLived()) {
// Exchanges a short-lived access token for a long-lived one
try {
$accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
} catch (Facebook\Exceptions\FacebookSDKException $e) {
print "<p>Error getting long-lived access token: " . $e->getMessage() . "</p>\n\n";
exit;
}
print '<h3>Long-lived</h3>';
var_dump($accessToken->getValue());
}
$_SESSION['fb_access_token'] = (string) $accessToken;
// User is logged in with a long-lived access token.
// You can redirect them to a members-only page.
header('Location: https://www.gangabiz.com/9.php');
I initially posted it as a bug to Facebook, however Xoe from Facebook bug support asked me to raise this issue with the community as they do not support php issues. Facebook closed the php bug mentioning the same.
The issue is happening because chromium-based browsers cannot understand that example.com and www.example.com are the same in this case gangabiz.com and www.gangabiz.com A htaccess redirect enforcing www solved the problem.
I'm trying to use the google calendar API (from a php script in cli mode) from an OVH shared server
( see: PHP quickstart )
After getting the code in the oAuthCallBack.php file, google gives me the following error:
cURL error 7: Failed to connect to oauth2.googleapis.com port 443: Connection refused
(see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
for https://oauth2.googleapis.com/token
OVH informs me that the concern does not come from them
and the server ip may be blacklisted
How can I resolve this problem ?
EDIT :
Minimal Example : (same problem with quick Start php code )
<?php
require __DIR__ . '/vendor/autoload.php';
if (php_sapi_name() != 'cli') {
throw new Exception('This application must be run on the command line.');
}
/**
* Returns an authorized API client.
* #return Google_Client the authorized client object
*/
function getClient() {
try {
$client = new Google_Client();
} catch (Exception $e) {
echo "Erreur getClient :" . $e->getMessage();
exit;
}
$client->setApplicationName('Google Calendar API PHP Quickstart');
$client->setScopes(Google_Service_Calendar::CALENDAR);
$client->setAuthConfig('credentials.json');
$client->setAccessType('offline');
$client->setPrompt('select_account consent');
$tokenPath = 'token.json';
if (file_exists($tokenPath)) {
$accessToken = json_decode(file_get_contents($tokenPath), true);
$client->setAccessToken($accessToken);
}
// If there is no previous token or it's expired.
if ($client->isAccessTokenExpired()) {
// Refresh the token if possible, else fetch a new one.
if ($client->getRefreshToken()) {
$client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
} else {
// Request authorization from the user.
$authUrl = $client->createAuthUrl();
printf("Open the following link in your browser:\n%s\n", $authUrl);
print 'Enter verification code: ';
$authCode = trim(fgets(STDIN));
// Exchange authorization code for an access token.
$accessToken = $client->fetchAccessTokenWithAuthCode($authCode);
$client->setAccessToken($accessToken);
// Check to see if there was an error.
if (array_key_exists('error', $accessToken)) {
throw new Exception(join(', ', $accessToken));
}
}
// Save the token to a file.
if (!file_exists(dirname($tokenPath))) {
mkdir(dirname($tokenPath), 0700, true);
}
file_put_contents($tokenPath, json_encode($client->getAccessToken()));
}
return $client;
}
try{
// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Calendar($client);
// Print the next 10 events on the user's calendar.
$calendarId = 'primary';
$optParams = array(
'maxResults' => 3,
'orderBy' => 'startTime',
'singleEvents' => true,
'timeMin' => '2021-03-18T10:22:53+01:00', // date('c')
);
$results = $service->events->listEvents($calendarId, $optParams);
$events = $results->getItems();
if (empty($events)) {
print "No upcoming events found.\n";
} else {
foreach ($events as $event) {
$start = $event->start->dateTime;
if (empty($start)) {
$start = $event->start->date;
}
$end = $event->end->dateTime;
if (empty($end)) {
$end = $event->end->date;
}
$id = trim($event->getId());
$etag = $event->etag;
$htmlLink = $event->htmlLink;
$summary = $event->summary;
$iCalUID = $event->iCalUID;
$description = str_replace("\r\n", "<br>", nl2br(htmlspecialchars($event->description)));
if ($description == "description test") {
//print_r($event);
echo " => ID: $id - iCalUID: $iCalUID | " . $etag . " | " . $summary . " | " . $htmlLink . " | " . $start . " - " . $end . " | " . $description . PHP_EOL;
}
}
}catch(Exception $e){
echo PHP_EOL . $e->getMessage() . PHP_EOL ;
}
Step 4: Run the sample
Run the sample using the following command:
php quickstart.php
The first time you run the sample, it will prompt you to authorize access:
Browse to the provided URL in your web browser.
If you are not already signed in to your Google account, you are be prompted to sign in. If you are signed in to multiple Google accounts, you are asked to select one account to use for the authorization.
Click the Accept button.
Copy the code you're given, paste it into the command-line prompt, and press Enter.
The error appears here!
To see it, I just added a try / catch block in the code
The problem is not related to the php code, but to the creation of the token.json which it cannot recover from the google servers.
It seems that it is related to an access denied to the ip of the ovh server on which the site is running.
NB: this code works perfectly from a dedicated server.
Thanks,
Jordane
I want to link and view the analytics account linked with Google Adwords.
Procedure used:
Authenticating google account with scopes "Ananlytics and Adwords" with following url
https://www.googleapis.com/auth/adwords
https://www.googleapis.com/auth/analytics
After getting the authentication response creating Google analytics service object.
Google ads link API throwing error "Insufficient Premissions" screenshot attached
Script :
<?php
//function to authenticate google account and create analytics service object
function googleAuth(){
if (!empty($code)) {
$postFields = 'client_id=' . Configure::read('GOOGLE_OAUTH_CLIENT_ID') . '&client_secret=' . Configure::read('GOOGLE_OAUTH_CLIENT_SECRET') . '&code=' . $code . '&grant_type=authorization_code&redirect_uri=' . Configure::read('GOOGLE_OAUTH_REDIRECT_URI');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://accounts.google.com/o/oauth2/token');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$Rec_Data = curl_exec($ch);
if (curl_exec($ch) === false) {
return $Rec_Data;
}
$Rec_Data = json_decode($Rec_Data, true);
if (isset($Rec_Data['refresh_token'])) {
try {
$credentials = array('client_id' => Configure::read('GOOGLE_OAUTH_CLIENT_ID'), 'client_secret' => Configure::read('GOOGLE_OAUTH_CLIENT_SECRET'), 'redirect_uris' => array(Configure::read('GOOGLE_OAUTH_REDIRECT_URI')));
$client = new \Google_Client($credentials);
$client->addScope(\Google_Service_Analytics::ANALYTICS_READONLY);
$client->setAccessToken($Rec_Data['access_token']);
// Create an authorized analytics service object.
$analytics = new \Google_Service_Analytics($client);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
die();
}
}
} else {
if (!empty($id)) {
header("Location:https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=" . Configure::read('GOOGLE_OAUTH_CLIENT_ID') . "&redirect_uri=" . Configure::read('GOOGLE_OAUTH_REDIRECT_URI') . "&access_type=offline&approval_prompt=force&state=" . $id . "&scope=https://www.googleapis.com/auth/adwords https://www.googleapis.com/auth/analytics");
exit;
}
}
}
//function to fetch linked account list
function adwordsLinkAnalytics($analyticsAuth) {
$this->autoRender = false;
try {
$adWordsLinks = $analyticsAuth->management_webPropertyAdWordsLinks
->listManagementwebPropertyAdWordsLinks('123456', 'UA-123456-1');
} catch (apiServiceException $e) {
print 'There was an Analytics API service error '
. $e->getCode() . ':+' . $e->getMessage();
exit;
} catch (apiException $e) {
print 'There was a general API error '
. $e->getCode() . ':-' . $e->getMessage();
exit;
}
pr($adWordsLinks);
exit;
}
Required result: List of the analytics account linked with adwords account.
You are missing scope to management entities in Google Analytics, please look at this https://developers.google.com/identity/protocols/oauth2/scopes#analytics
Please update your scope with "https://www.googleapis.com/auth/analytics.edit"
My suggested Updates:
function googleAuth(){
if (!empty($code)) {
--------------
---- Your existing script ----
--------------
} else {
if (!empty($id)) {
header("Location:https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=" . Configure::read('GOOGLE_OAUTH_CLIENT_ID') . "&redirect_uri=" . Configure::read('GOOGLE_OAUTH_REDIRECT_URI') . "&access_type=offline&approval_prompt=force&state=" . $id . "&scope=https://www.googleapis.com/auth/adwords%20https://www.googleapis.com/auth/analytics%20https://www.googleapis.com/auth/analytics.edit");
exit;
}
}
}
Reference Url: https://developers.google.com/identity/protocols/oauth2/scopes#analytics
I want to get following local insights of Facebook page using graph API
People Nearby:Hourly
Weekly
Overall
Check-ins
Please see the screen shot.
Image
You can get page insights by using this code and ask for page permissions ('manage_pages','pages_manage_cta') , and get page id first from your likes or managed pages and replace you page id in code with YOUR_PAGE_ID.
use FB php sdk version: facebook-php-sdk-v4-5.0-dev.
$fb = new Facebook\Facebook([
'app_id' => APP_ID,
'app_secret' => APP_SECRET,
'default_graph_version' => 'v2.4', // or use v2.5 latest version
]);
$helper = $fb->getRedirectLoginHelper();
$permissions = ['manage_pages','pages_manage_cta'];
$redirectUrl = 'http://localhost/fbapp.php';
$loginUrl = $helper->getLoginUrl($redirectUrl, $permissions);
echo 'Log in with Facebook!';
After generating login url implement the code for response handling and getting required data.
$helper = $fb->getRedirectLoginHelper();
try {
$accessToken = $helper->getAccessToken();
setcookie('accessToken',$accessToken);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$fb->setDefaultAccessToken($accessToken);
// Get user groups detail
$requestPageInsights = $fb->request('GET', '/YOUR_PAGE_ID/insights');
//Make a batch request
$batch = ['page-insights' => $requestPageInsights];
try {
$responses = $fb->sendBatchRequest($batch);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
for a better view can use this:
foreach ($responses as $key => $response) {
if ($response->isError()) {
$e = $response->getThrownException();
echo '<p>Error! Facebook SDK Said: ' . $e->getMessage() . "\n\n";
echo '<p>Graph Said: ' . "\n\n";
var_dump($e->getResponse());
} else {
echo "<p>(" . $key . ") HTTP status code: " . $response->getHttpStatusCode() . "<br />\n";
echo "Response: " . $response->getBody() . "</p>\n\n";
echo "<hr />\n\n";
}
}
And for getting other details visit on and use your related params/scope https://developers.facebook.com/docs/graph-api/reference/v2.5/insights
I have been trying to get the google api php client to work on app engine. After reading the app.yaml configuration resources provided by the documentation, I have still not been able to get this to work. My app.yaml has the google-api-php-client as it follows:
- url: /google-api-php-client/(.*?)/(.*?)/(.*)
script: google-api-php-client/\3/\2/\1.php
And, the structure of the folder is:
google-api-php-client->(some_folders)->(some_folders+files)->(some_files)
| level1 | | level2 | | level3 | | level4 |
I would like to have the configuration set so that I would be able to access the files in level 3 and level 4 and be able to do require_once calls just like these:
require_once ('/google-api-php-client/src/Google_Client.php');
require_once ('/google-api-php-client/src/contrib/Google_DriveService.php');
I am able to do these require_once calls on localhost but not when I deploy the files to app engine. The logs on app engine dashboard show this:
PHP Fatal error: require_once(): Failed opening required '/google-api-php-client/src/Google_Client.php' (include_path='.;/base/data/home/apps/s~...
I would appreciate any and all input.
Thanks!
EDIT: I am adding the code where I'm using require_once
require_once ('google-api-php-client/src/Google_Client.php');
require_once ('google-api-php-client/src/contrib/Google_DriveService.php');
session_start();
$client = new Google_Client();
$client->setApplicationName("Drive Demo");
$client->setClientId('****');
$client->setClientSecret('****');
$client->setRedirectUri('http://localhost:8080');
$client->setDeveloperKey('****');
$client->setScopes(array(
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile'));
$client->setAccessType('offline');
$service = new Google_DriveService($client);
$fileId = '****';
function printFile($service, $fileId) {
try {
$file = $service->files->get($fileId);
print_r($file);
print "Title: " . $file->getTitle();
print "Description: " . $file->getDescription();
print "MIME type: " . $file->getMimeType();
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
}
}
function retrieveAllFiles($service) {
$result = array();
$pageToken = NULL;
do {
try {
$parameters = array('q'=>'', 'maxResults'=> '25', 'fields'=>'items(title,description,mimeType)');
if ($pageToken) {
$parameters['pageToken'] = $pageToken;
}
$files = $service->files->listFiles($parameters);
$result = array_merge($result, $files->getItems());
$pageToken = $files->getNextPageToken();
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
$pageToken = NULL;
}
} while ($pageToken);
return $result;
}
if (!isset($_REQUEST['code']) && !isset($_SESSION['access_token'])) {
$authUrl = $client->createAuthUrl();
print("<a href='".$authUrl."'>Authorize me</a>");
}else {
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
}
if (isset($_SESSION['access_token'])) {
$client->setAccessToken($_SESSION['access_token']);
}
if ($client->getAccessToken()) {
$_SESSION['access_token'] = $client->getAccessToken();
}
$files = retrieveAllFiles($service);
foreach($files as $file){
//print_r($file);
print "Title: " . $file->getTitle().'<br/>';
print "Description: " . $file->getDescription().'<br/>';
print "MIME type: " . $file->getMimeType().'<br/>';
}
}
Update: Removed the '/' as per #Stuart's comment, which solved the issue.
You don't need to configure app.yaml in this case - as you don't want to route any requests directly to these scripts.
Just put the source code for google-api-php-client in the same directory as your app and deploy it using appcfg.py.
Check my article on configuring the client here.