Hello, i try to migrate to new google ads api and try to make request. 
<?php

require 'vendor/autoload.php';

use GetOpt\GetOpt;
use Google\Ads\GoogleAds\Examples\Utils\ArgumentNames;
use Google\Ads\GoogleAds\Examples\Utils\ArgumentParser;
use Google\Ads\GoogleAds\Lib\V8\GoogleAdsClient;
use Google\Ads\GoogleAds\Lib\V8\GoogleAdsClientBuilder;
use Google\Ads\GoogleAds\Lib\V8\GoogleAdsException;
use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder;
use Google\Ads\GoogleAds\Lib\V8\GoogleAdsServerStreamDecorator;
use Google\Ads\GoogleAds\V8\Errors\GoogleAdsError;
use Google\Ads\GoogleAds\V8\Services\GoogleAdsRow;
use Google\ApiCore\ApiException;
ini_set('memory_limit', '700M');
$devToken = "my_dev_token";
$refreshToken = "my_refresh_token";
$clientId = "my_client_id";
$clientSecret = "my_client_secret";
$oAuth2Credential = (new OAuth2TokenBuilder())
->withClientId($clientId)
->withClientSecret($clientSecret)
->withRefreshToken($refreshToken)
-> build();
$googleAdsClient = (new GoogleAdsClientBuilder())
    ->withDeveloperToken($devToken)
    ->withLoginCustomerId("my_login_customer_id")
    ->withOAuth2Credential($oAuth2Credential)
    ->build();
    runExample($googleAdsClient,"my_login_customer_id");
function runExample(GoogleAdsClient $googleAdsClient, int $customerId)
    {
        $googleAdsServiceClient = 
$googleAdsClient->getGoogleAdsServiceClient();
        $query = 'SELECT campaign.id, campaign.name FROM campaign ORDER BY 
campaign.id';
        $stream =
            $googleAdsServiceClient->searchStream($customerId, $query);
        foreach ($stream->iterateAllElements() as $googleAdsRow) {
            printf(
                "Campaign with ID %d and name '%s' was found.%s",
                $googleAdsRow->getCampaign()->getId(),
                $googleAdsRow->getCampaign()->getName(),
                PHP_EOL
            );
        }
    }
?>
But i have an error like this 

 "message": "The caller does not have permission",

    "code": 7,

    "status": "PERMISSION_DENIED",

    "details": [

        {

            "@type": "google.ads.googleads.v8.errors.googleadsfailure-bin",

            "data": "<Unknown Binary Data>"

        },

        {

            "@type": "grpc-status-details-bin",

            "data": "<Unknown Binary Data>"

        },

        {

            "@type": "request-id",

            "data": "2mlrxVNlSUwrj7F9HjOwPg"

        }

    ]

}

Someone have an idea what to do ?

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/32f67ac3-c5df-4002-b3e9-2dcf546513b4n%40googlegroups.com.
  • Goo... 'Гордей Строкин' via AdWords API and Google Ads API Forum
    • ... Google Ads API Forum Advisor
      • ... 'Гордей Строкин' via AdWords API and Google Ads API Forum
        • ... Google Ads API Forum Advisor

Reply via email to