From 4839c87e76bf221ea91409e4cc093b608b0f8481 Mon Sep 17 00:00:00 2001 From: Steve <34465153+xxl4@users.noreply.github.com> Date: Thu, 12 Sep 2024 13:17:45 +0800 Subject: [PATCH] fix google adsense --- src/Config/GoogleAdsense.php | 7 +++++++ src/Http/Controllers/Api/GoogleAdsenseController.php | 8 +++++--- src/Http/Controllers/Web/GoogleAdsenseController.php | 7 ++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Config/GoogleAdsense.php b/src/Config/GoogleAdsense.php index abbaab3..e9bec35 100644 --- a/src/Config/GoogleAdsense.php +++ b/src/Config/GoogleAdsense.php @@ -117,4 +117,11 @@ */ 'RedirectUri' => 'http://localhost:8000/googleadsense/callback', + + /** + * + * Google Adsense Auth Config File + * + */ + 'auth_config_file' => storage_path('app/client_secret_33839582772-7bqi2gto92jms75ujbhvfo22je2haold.apps.googleusercontent.com.json'), ]; \ No newline at end of file diff --git a/src/Http/Controllers/Api/GoogleAdsenseController.php b/src/Http/Controllers/Api/GoogleAdsenseController.php index 63204f0..0268aa9 100644 --- a/src/Http/Controllers/Api/GoogleAdsenseController.php +++ b/src/Http/Controllers/Api/GoogleAdsenseController.php @@ -26,11 +26,13 @@ public function __construct() //$this->middleware('permission:report-google-adsense', ['only' => ['googleAdsense']]); $this->client = new Google_Client(); - $this->client->addScope('https://www.googleapis.com/auth/adsense.readonly'); - $this->client->addScope('https://www.googleapis.com/auth/adsense'); + // $this->client->addScope('https://www.googleapis.com/auth/adsense.readonly'); + // $this->client->addScope('https://www.googleapis.com/auth/adsense'); + $this->client->addScope(config('GoogleAdsense.Scopes')); $this->client->setAccessType('offline'); $this->client->setApprovalPrompt('force'); - $this->client->setAuthConfig(storage_path('app/client_secret_33839582772-7bqi2gto92jms75ujbhvfo22je2haold.apps.googleusercontent.com.json')); + //$this->client->setAuthConfig(storage_path('app/client_secret_33839582772-7bqi2gto92jms75ujbhvfo22je2haold.apps.googleusercontent.com.json')); + $this->client->setAuthConfig(config('GoogleAdsense.auth_config_file')); $this->client->setRedirectUri(route('googleadsense.web.googleadsense.callback')); diff --git a/src/Http/Controllers/Web/GoogleAdsenseController.php b/src/Http/Controllers/Web/GoogleAdsenseController.php index 0cae348..43a50a7 100644 --- a/src/Http/Controllers/Web/GoogleAdsenseController.php +++ b/src/Http/Controllers/Web/GoogleAdsenseController.php @@ -14,11 +14,12 @@ class GoogleAdsenseController extends Controller public function __construct() { $this->client = new Google_Client(); - $this->client->addScope('https://www.googleapis.com/auth/adsense.readonly'); - $this->client->addScope('https://www.googleapis.com/auth/adsense'); + // $this->client->addScope('https://www.googleapis.com/auth/adsense.readonly'); + // $this->client->addScope('https://www.googleapis.com/auth/adsense'); + $this->client->addScope(config('GoogleAdsense.Scopes')); $this->client->setAccessType('offline'); $this->client->setApprovalPrompt('force'); - $this->client->setAuthConfig(storage_path('app/client_secret_33839582772-7bqi2gto92jms75ujbhvfo22je2haold.apps.googleusercontent.com.json')); + $this->client->setAuthConfig(config('GoogleAdsense.auth_config_file')); } public function index()