Advanced access to Google API (Working with Google Analytics API)
1. Setup
First, we need to activate access to Google Analytics API by going to https://code.google.com/apis/console/ > All services > Analytics API:

Then, we need to add 'https://www.googleapis.com/auth/analytics.readonly" to the requested scope on hybridauth configuration file:
- "Google" => array (
- "enabled" => true,
- "keys" => array ( "id" => "", "secret" => "" ),
- "scope" => "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/analytics.readonly"
- ),
2. Use Hybrid_Providers_Google::api() to make appropriate Google API calls:
- <?php
- $hybridauth = new Hybrid_Auth( $config );
-
- $google = $hybridauth->authenticate( "Google" );
-
- $data = $google->api()->api( "https://www.googleapis.com/analytics/v3/management/accounts" );
-
- print_r( $data );
- <?php
- $hybridauth = new Hybrid_Auth( $config );
- $google = $hybridauth->authenticate( "Google" );
- $data = $google->api()->api( "https://www.googleapis.com/analytics/v3/management/accounts" );
- print_r( $data );
* For more information about Google Analytics API you can refer to https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/.