没有任何广告账号则自动解绑授权 2

This commit is contained in:
huangguancheng 2025-02-22 19:35:13 +08:00
parent 4dbc21ebfa
commit 9323e69abd

View File

@ -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