This extensions provides a wrapper to googles google-api-php-client library providing an easy way to access google apis and authentication via 2- or 3-legged auth mechanisms. The extension is intended to enable any app to access google apis, perform authentication and get listed on google marketplace.
Requirements ¶
Yii 1.1 or above
Installation ¶
Copy the GoogleApis folder into extensions.
Configuration ¶
'components' => array(
// ...
'GoogleApis' => array(
'class' => 'ext.GoogleApis.GoogleApis',
// See http://code.google.com/p/google-api-php-client/wiki/OAuth2
'clientId' => 'YOUR_CLIENT_ID',
'clientSecret' => 'YOUR_CLIENT_SECRET',
'redirectUri' => 'YOUR_REDIRECT_URI',
// // This is the API key for 'Simple API Access'
'developerKey' => 'YOUR_DEVELOPER_KEY',
),
// ...
Usage ¶
/**
* @var apiPlusService $service
*/
$plus = Yii::app()->GoogleApis->serviceFactory('Plus');
/**
* @var apiClient $client
*/
$client = Yii::app()->GoogleApis->client;
Try {
if(!isset(Yii::app()->session['auth_token'])
|| is_null(Yii::app()->session['auth_token']))
// You want to use a persistence layer like the DB for storing this along
// with the current user
Yii::app()->session['auth_token'] = $client->authenticate();
else
$activities = '';
$client->setAccessToken(Yii::app()->session['auth_token']);
$activities = $plus->activities->listActivities('me', 'public');
print 'Your Activities: <pre>' . print_r($activities, true) . '</pre>';
} catch(Exception $e) {
// This needs some love as not every exception means that the token
// was invalidated
Yii::app()->session['auth_token'] = null;
throw $e;
}
Todo ¶
Test and provide samples for Google Marketplace (2-legged-auth).
Typo?
I believe you need a $client->setAccessToken(Yii::app()->session['auth_token']);
inside the else block
acccess to docs on google drive
Any chance I could use this ext to read-write docs on google drive?
@docnewman
Thank you.
@radoo
I need to look into it.
form api
Thank you for the extension.
How can i use form api in the extension?
apiAuthException Could not json decode the access token
Error:
apiAuthException Could not json decode the access token
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.