У меня есть аккаунт Google Ads Manager с ключом разработчика (он находится в тестовом режиме, если это имеет значение). ?). Электронная почта, которую я пытаюсь использовать для аутентификации любым методом, принадлежит администратору в домене и соответствующих учетных записях Ads Manager и Ads.
Что бы я ни делал, я получаю следующую ошибку .
Код: Выделить всё
{
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https:\/\/developers.google.com\/identity\/sign-in\/web\/devconsole-project.",
"code": 16,
"status": "UNAUTHENTICATED",
"details": [
{
"@type": "type.googleapis.com\/google.ads.googleads.v16.errors.GoogleAdsFailure",
"errors": [
{
"errorCode": {
"authenticationError": "OAUTH_TOKEN_HEADER_INVALID"
},
"message": "Oauth token HTTP header is malformed."
}
],
"requestId": "9QCN5RO9mRkmS1ULtDAKMA"
}
]
}
Это в проекте Laravel.
Код: Выделить всё
$oauth2 = (new OAuth2TokenBuilder())
->withClientId(config('google.client_id'))
->withClientSecret(config('google.client_secret'))
->withRefreshToken(config('googleads.refresh_token'))
->build();
Код: Выделить всё
$oauth2 = (new OAuth2TokenBuilder())
->withJsonKeyFilePath(realpath(config('google.service.file')))
->withScopes('https://www.googleapis.com/auth/adwords')
->withImpersonatedEmail(config('googleads.impersonated_email'))
->build();
Вот как устроен мой GoogleAdsClient:
< pre class="lang-php Prettyprint-override">
Код: Выделить всё
$this->client = (new GoogleAdsClientBuilder())
->withOAuth2Credential($oauth2)
->withDeveloperToken(config('google.developer_key'))
->usingGapicV2Source(true)
->build();
Код: Выделить всё
$requestArgs = [
// Set the language resource using the provided language ID.
'language' => $this->getLanguageConstant(),
'customer_id' => $this->getCustomerId(),
// Add the resource name of each location ID to the request. - currently an empty array
'geo_target_constants' => $this->getGeoTargetConstants(),
// Set the network. To restrict to only Google Search, change the parameter below to
'keyword_plan_network' => KeywordPlanNetwork::GOOGLE_SEARCH,
] + $requestOptionalArgs;
$response = $ideaClient->generateKeywordIdeas(
new GenerateKeywordIdeasRequest($requestArgs)
);
Подробнее здесь: https://stackoverflow.com/questions/781 ... -or-servic
Мобильная версия