我正在与Google Adwords集成。
我使用Google的图书馆googleads/googleads-php-lib
。
我从Google那里收到了refreshToken
,但是当我尝试获取客户数据时,却从soap中获取了一个例外:
[AuthenticationError.OAUTH_TOKEN_INVALID @;触发:“ null”]
我的代码:
$oAuth2Credential = (new OAuth2TokenBuilder())
->from($config)
->build();
$session = (new AdWordsSessionBuilder())
->from($config)
->withOAuth2Credential($oAuth2Credential)
->withDeveloperToken('uBFZEv...-lx1g')
->build();
/** @var CampaignService $campaignService */
$campaignService = $this->adWordsServices->get($session, CampaignService::class);
$selector = new Selector();
$selector->setFields(['Id', 'Name']);
$campaigns = $campaignService->get($selector); // exception appears here
dump($campaigns);
如果致电$oAuth2Credential->fetchAuthToken();
我得到access_token
,一切看起来都很好。
我在做什么错了?