如何解决“ [AuthenticationError.OAUTH_TOKEN_INVALID @;触发条件:'<null>']'

时间:2019-01-29 11:11:08

标签: php google-api google-oauth2

我正在与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,一切看起来都很好。

我在做什么错了?

0 个答案:

没有答案