googleAds广告账号-授权-绑定-激活流程更新 fixed revokeRefreshToken
This commit is contained in:
parent
16e84fa518
commit
88a5e048af
@ -8,6 +8,7 @@ use support\Request;
|
||||
use support\Response;
|
||||
use DI\Annotation\Inject;
|
||||
use app\model\ThirdUserAdvertiser;
|
||||
use app\model\BpsAdsMerchantRelation;
|
||||
use app\model\ThirdUser;
|
||||
use support\Redis;
|
||||
|
||||
@ -188,16 +189,17 @@ class OAuthController
|
||||
$merchant_id = $request->input('merchant_id') ?? $request->jwtClaims['merchant_id'];
|
||||
|
||||
// 通过 advertiser_id 查询 ThirdUserAdvertiser,联表查询 ThirdUser 数据
|
||||
$thirdUser = ThirdUser::where('merchant_id', $merchant_id)->where('third_type', 'google')->find(); // 获取第一个结果
|
||||
$thirdUser = BpsAdsMerchantRelation::where('merchant_id', $merchant_id)->where('platform', 2)->find(); // 获取第一个结果
|
||||
// dump($thirdUser); return ($uid);
|
||||
if (!$thirdUser) {
|
||||
return $this->errorResponse(300, '未授权');
|
||||
}
|
||||
// dump($userAdvertiser->googleUser->access_token);
|
||||
$accessToken = $thirdUser->access_token;
|
||||
// dump($accessToken);
|
||||
// return ($merchant_id);
|
||||
|
||||
$googleOAuthService = new GoogleOAuthService();
|
||||
$googleOAuthService->revokeToken($accessToken, $thirdUser->id);
|
||||
$googleOAuthService->revokeToken($accessToken, $merchant_id);
|
||||
return $this->successResponse(['deleted' => 'success'], $request);
|
||||
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class GoogleOAuthService
|
||||
{
|
||||
$clientId = getenv('GOOGLE_CLIENT_ID');
|
||||
$redirectUri = getenv('GOOGLE_REDIRECT_URI');
|
||||
$scope = 'https://www.googleapis.com/auth/adwords';
|
||||
$scope = 'https://www.googleapis.com/auth/adwords https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email';
|
||||
$responseType = 'code';
|
||||
$accessType = 'offline';
|
||||
|
||||
@ -332,7 +332,7 @@ class GoogleOAuthService
|
||||
$this->queue($options);
|
||||
}
|
||||
|
||||
public function revokeToken($accessToken, $third_user_id)
|
||||
public function revokeToken($accessToken, $merchantId)
|
||||
{
|
||||
$client = new Client();
|
||||
$client->post('https://oauth2.googleapis.com/revoke', [
|
||||
@ -342,18 +342,18 @@ class GoogleOAuthService
|
||||
]);
|
||||
|
||||
// 在数据库中删除或标记该`access_token(其实是refresh_token)`为无效
|
||||
ThirdUserAdvertiser::where('doc_', $third_user_id)->delete();
|
||||
|
||||
$tableName = 'bps_third_user';
|
||||
$tableName = getenv('DB_PG_SCHEMA') ? getenv('DB_PG_SCHEMA') . '.' . $tableName : 'bps' . $tableName;
|
||||
$sql = "UPDATE {$tableName} SET access_token = :access_token WHERE id = :id";
|
||||
$data = [
|
||||
'access_token' => '', // 这里的 $accessToken 是您想要匹配的值
|
||||
'id' => $third_user_id, // 这里的 $accessToken 是您想要匹配的值
|
||||
];
|
||||
// 执行 SQL 语句
|
||||
$result = ThinkDb::execute($sql, $data);
|
||||
// ThirdUser::where('access_token', $accessToken)->delete();
|
||||
BpsAdsMerchantRelation::where('merchant_id', $merchantId)->where('platform',2)->delete();
|
||||
//
|
||||
// $tableName = 'bps_third_user';
|
||||
// $tableName = getenv('DB_PG_SCHEMA') ? getenv('DB_PG_SCHEMA') . '.' . $tableName : 'bps' . $tableName;
|
||||
// $sql = "UPDATE {$tableName} SET access_token = :access_token WHERE id = :id";
|
||||
// $data = [
|
||||
// 'access_token' => '', // 这里的 $accessToken 是您想要匹配的值
|
||||
// 'id' => $third_user_id, // 这里的 $accessToken 是您想要匹配的值
|
||||
// ];
|
||||
// // 执行 SQL 语句
|
||||
// $result = ThinkDb::execute($sql, $data);
|
||||
//// ThirdUser::where('access_token', $accessToken)->delete();
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user