From 9323e69abda0f53afb1efe9e2e9983d6f62b2ac3 Mon Sep 17 00:00:00 2001
From: huangguancheng <huangguancheng@bestfulfill>
Date: Sat, 22 Feb 2025 19:35:13 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E4=BB=BB=E4=BD=95=E5=B9=BF?=
 =?UTF-8?q?=E5=91=8A=E8=B4=A6=E5=8F=B7=E5=88=99=E8=87=AA=E5=8A=A8=E8=A7=A3?=
 =?UTF-8?q?=E7=BB=91=E6=8E=88=E6=9D=83=202?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/controller/OAuthController.php | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/app/controller/OAuthController.php b/app/controller/OAuthController.php
index 73b6a9c..3ecddbc 100644
--- a/app/controller/OAuthController.php
+++ b/app/controller/OAuthController.php
@@ -107,13 +107,16 @@ class OAuthController
             //如果这个授权用户名下没有任何广告账号
             $option                  = [];
             $option['refresh_token'] = $tokens['refresh_token'];
-
-            $listAccessibleCustomers = $this->googleAdsAccountService->runListAccessibleCustomers($option);
+            try {
+                $listAccessibleCustomers = $this->googleAdsAccountService->runListAccessibleCustomers($option);
+            }catch (\Exception $e) {
+                return $this->errorResponse(300, 'The Google account (@gmail.com user) that generated the OAuth access tokens is not associated with any Ads accounts. Create a new account, or add the Google account to an existing Ads account.');
+            }
             if (empty($listAccessibleCustomers)) {
                 $googleOAuthService = new GoogleOAuthService();
                 $googleOAuthService->revokeToken($tokens['refresh_token'], $merchantId);
 
-                return $this->errorResponse(300, 'has not any google ads account');
+                return $this->errorResponse(300, 'The Google account (@gmail.com user) that generated the OAuth access tokens is not associated with any active Ads accounts. Create a active account and try again.');
             }
 
 //            $googleOAuthService->saveRefreshToken($tokens['refresh_token'], $state); //作废2025-2-13