profile_id)) { throw new ApplicationException(trans('rainlab.googleanalytics::lang.strings.notconfigured')); } if (!$settings->gapi_key) { throw new ApplicationException(trans('rainlab.googleanalytics::lang.strings.keynotuploaded')); } $client = new Google_Client(); /* * Set caching */ $cache = App::make(CacheItemPool::class); $client->setCache($cache); /* * Set assertion credentials */ $auth = json_decode($settings->gapi_key->getContents(), true); $client->setAuthConfig($auth); $client->addScope(Google_Service_Analytics::ANALYTICS_READONLY); if ($client->isAccessTokenExpired()) { $client->refreshTokenWithAssertion(); } $this->client = $client; $this->service = new Google_Service_Analytics($client); $this->viewId = 'ga:'.$settings->profile_id; } }