You are here

function _gauth_read_scope_info in Google Auth 7

Same name and namespace in other branches
  1. 8 gauth.module \_gauth_read_scope_info()
  2. 7.2 gauth.module \_gauth_read_scope_info()

Helper function which reads the installed library and discovery api to build cache for scopes and names.

2 calls to _gauth_read_scope_info()
gauth_google_services_names in ./gauth.module
Returns a array services api names.
gauth_google_services_scopes in ./gauth.module
Returns a array services api versions.

File

./gauth.module, line 268
Google Auth Api for drupal.

Code

function _gauth_read_scope_info() {
  $library = libraries_load('google-api-php-client');
  $path = $library['library path'] . '/vendor/google/apiclient-services/src/Google/Service/';
  $files = scandir($path);
  $names = array(
    'abusiveexperiencereport' => 'Abusive Experience Report API',
    'acceleratedmobilepageurl' => 'Accelerated Mobile Pages (AMP) URL API',
    'accessapproval' => 'Access Approval API',
    'accesscontextmanager' => 'Access Context Manager API',
    'adexchangebuyer' => 'Ad Exchange Buyer API',
    'adexchangebuyer2' => 'Ad Exchange Buyer API II',
    'adexperiencereport' => 'Ad Experience Report API',
    'admin' => 'Admin Reports API',
    'adsense' => 'AdSense Management API',
    'adsensehost' => 'AdSense Host API',
    'alertcenter' => 'G Suite Alert Center API',
    'analytics' => 'Google Analytics API',
    'analyticsreporting' => 'Analytics Reporting API',
    'androiddeviceprovisioning' => 'Android Device Provisioning Partner API',
    'androidenterprise' => 'Google Play EMM API',
    'androidmanagement' => 'Android Management API',
    'androidpublisher' => 'Google Play Developer API',
    'appengine' => 'App Engine Admin API',
    'appsactivity' => 'Drive Activity API',
    'bigquery' => 'BigQuery API',
    'bigqueryconnection' => 'BigQuery Connection API',
    'bigquerydatatransfer' => 'BigQuery Data Transfer API',
    'bigqueryreservation' => 'BigQuery Reservation API',
    'bigtableadmin' => 'Cloud Bigtable Admin API',
    'binaryauthorization' => 'Binary Authorization API',
    'blogger' => 'Blogger API',
    'books' => 'Books API',
    'calendar' => 'Calendar API',
    'chat' => 'Hangouts Chat API',
    'civicinfo' => 'Google Civic Information API',
    'classroom' => 'Google Classroom API',
    'cloudasset' => 'Cloud Asset API',
    'cloudbilling' => 'Cloud Billing API',
    'cloudbuild' => 'Cloud Build API',
    'clouddebugger' => 'Stackdriver Debugger API',
    'clouderrorreporting' => 'Stackdriver Error Reporting API',
    'cloudfunctions' => 'Cloud Functions API',
    'cloudidentity' => 'Cloud Identity API',
    'cloudiot' => 'Cloud IoT API',
    'cloudkms' => 'Cloud Key Management Service (KMS) API',
    'cloudprivatecatalog' => 'Cloud Private Catalog API',
    'cloudprivatecatalogproducer' => 'Cloud Private Catalog Producer API',
    'cloudprofiler' => 'Stackdriver Profiler API',
    'cloudresourcemanager' => 'Cloud Resource Manager API',
    'cloudscheduler' => 'Cloud Scheduler API',
    'cloudsearch' => 'Cloud Search API',
    'cloudshell' => 'Cloud Shell API',
    'cloudtasks' => 'Cloud Tasks API',
    'cloudtrace' => 'Stackdriver Trace API',
    'commentanalyzer' => 'Perspective Comment Analyzer API',
    'composer' => 'Cloud Composer API',
    'compute' => 'Compute Engine API',
    'container' => 'Kubernetes Engine API',
    'containeranalysis' => 'Container Analysis API',
    'content' => 'Content API for Shopping',
    'customsearch' => 'CustomSearch API',
    'dataflow' => 'Dataflow API',
    'datafusion' => 'Cloud Data Fusion API',
    'dataproc' => 'Cloud Dataproc API',
    'datastore' => 'Cloud Datastore API',
    'deploymentmanager' => 'Google Cloud Deployment Manager API',
    'dfareporting' => 'DCM/DFA Reporting And Trafficking API',
    'dialogflow' => 'Dialogflow API',
    'digitalassetlinks' => 'Digital Asset Links API',
    'discovery' => 'API Discovery Service',
    'dlp' => 'Cloud Data Loss Prevention (DLP) API',
    'dns' => 'Google Cloud DNS API',
    'docs' => 'Google Docs API',
    'domainsrdap' => 'Domains RDAP API',
    'doubleclickbidmanager' => 'DoubleClick Bid Manager API',
    'doubleclicksearch' => 'Search Ads 360 API',
    'drive' => 'Drive API',
    'driveactivity' => 'Drive Activity API',
    'factchecktools' => 'Fact Check Tools API',
    'fcm' => 'Firebase Cloud Messaging API',
    'file' => 'Cloud Filestore API',
    'firebase' => 'Firebase Management API',
    'firebasedynamiclinks' => 'Firebase Dynamic Links API',
    'firebasehosting' => 'Firebase Hosting API',
    'firebaserules' => 'Firebase Rules API',
    'firestore' => 'Cloud Firestore API',
    'fitness' => 'Fitness',
    'fusiontables' => 'Fusion Tables API',
    'games' => 'Google Play Game Services API',
    'gamesConfiguration' => 'Google Play Game Services Publishing API',
    'gamesManagement' => 'Google Play Game Services Management API',
    'genomics' => 'Genomics API',
    'gmail' => 'Gmail API',
    'groupsmigration' => 'Groups Migration API',
    'groupssettings' => 'Groups Settings API',
    'healthcare' => 'Cloud Healthcare API',
    'homegraph' => 'HomeGraph API',
    'iam' => 'Identity and Access Management (IAM) API',
    'iamcredentials' => 'IAM Service Account Credentials API',
    'iap' => 'Cloud Identity-Aware Proxy API',
    'identitytoolkit' => 'Google Identity Toolkit API',
    'indexing' => 'Indexing API',
    'jobs' => 'Cloud Talent Solution API',
    'kgsearch' => 'Knowledge Graph Search API',
    'language' => 'Cloud Natural Language API',
    'libraryagent' => 'Library Agent API',
    'licensing' => 'Enterprise License Manager API',
    'logging' => 'Stackdriver Logging API',
    'manufacturers' => 'Manufacturer Center API',
    'mirror' => 'Google Mirror API',
    'ml' => 'Cloud Machine Learning Engine',
    'monitoring' => 'Stackdriver Monitoring API',
    'oauth2' => 'Google OAuth2 API',
    'osconfig' => 'Cloud OS Config API',
    'oslogin' => 'Cloud OS Login API',
    'pagespeedonline' => 'PageSpeed Insights API',
    'people' => 'People API',
    'playcustomapp' => 'Google Play Custom App Publishing API',
    'plus' => 'Google+ API',
    'plusDomains' => 'Google+ Domains API',
    'poly' => 'Poly API',
    'proximitybeacon' => 'Proximity Beacon API',
    'pubsub' => 'Cloud Pub/Sub API',
    'redis' => 'Google Cloud Memorystore for Redis API',
    'remotebuildexecution' => 'Remote Build Execution API',
    'replicapool' => 'Replica Pool API',
    'reseller' => 'Enterprise Apps Reseller API',
    'run' => 'Cloud Run API',
    'runtimeconfig' => 'Cloud Runtime Configuration API',
    'safebrowsing' => 'Safe Browsing API',
    'script' => 'Apps Script API',
    'searchconsole' => 'Google Search Console URL Testing Tools API',
    'securitycenter' => 'Cloud Security Command Center API',
    'servicebroker' => 'Service Broker API',
    'serviceconsumermanagement' => 'Service Consumer Management API',
    'servicecontrol' => 'Service Control API',
    'servicemanagement' => 'Service Management API',
    'servicenetworking' => 'Service Networking API',
    'serviceusage' => 'Service Usage API',
    'sheets' => 'Google Sheets API',
    'siteVerification' => 'Google Site Verification API',
    'slides' => 'Google Slides API',
    'sourcerepo' => 'Cloud Source Repositories API',
    'spanner' => 'Cloud Spanner API',
    'speech' => 'Cloud Speech-to-Text API',
    'sqladmin' => 'Cloud SQL Admin API',
    'storage' => 'Cloud Storage JSON API',
    'storagetransfer' => 'Storage Transfer API',
    'streetviewpublish' => 'Street View Publish API',
    'surveys' => 'Surveys API',
    'tagmanager' => 'Tag Manager API',
    'tasks' => 'Tasks API',
    'testing' => 'Cloud Testing API',
    'texttospeech' => 'Cloud Text-to-Speech API',
    'toolresults' => 'Cloud Tool Results API',
    'tpu' => 'Cloud TPU API',
    'translate' => 'Cloud Translation API',
    'urlshortener' => 'URL Shortener API',
    'vault' => 'G Suite Vault API',
    'verifiedaccess' => 'Chrome Verified Access API',
    'videointelligence' => 'Cloud Video Intelligence API',
    'vision' => 'Cloud Vision API',
    'webfonts' => 'Google Fonts Developer API',
    'webmasters' => 'Search Console API',
    'websecurityscanner' => 'Web Security Scanner API',
    'youtube' => 'YouTube Data API',
    'youtubeAnalytics' => 'YouTube Analytics API',
    'youtubereporting' => 'YouTube Reporting API�',
  );
  $api_names = array();
  foreach ($files as $file) {
    if (substr($file, -3) == 'php') {
      require_once $path . $file;
      $cname = substr($file, 0, -4);
      $tname = strtolower($cname);
      if (isset($names[$tname])) {
        $api_names[$tname] = $names[$tname];
      }
      else {
        $api_names[$tname] = $cname;
      }
    }
  }
  $scopes = array();
  $client = gauth_client_get();
  foreach (get_declared_classes() as $class) {
    if (is_subclass_of($class, 'Google_Service')) {
      $classes[] = $class;
      $temp = new ReflectionClass($class);
      $instance = $temp
        ->newInstance($client);
      $aname = $instance->serviceName;
      if (!isset($api_names[$aname])) {
        $aname = $temp
          ->getName();
        $aname = strtolower(str_replace('Google_Service_', '', $aname));
      }
      $scopes[$aname] = $temp
        ->getConstants();
      cache_set($aname, $scopes[$aname], 'cache_gauth_scopes');
    }
  }
  variable_set('gauth_google_api_services', $api_names);
  return $scopes;
}