Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usage for hiearchy accounts #42

Open
gezimapi opened this issue Mar 19, 2019 · 3 comments
Open

usage for hiearchy accounts #42

gezimapi opened this issue Mar 19, 2019 · 3 comments

Comments

@gezimapi
Copy link

hi
i have to tried to list the accounts in my mcc using:

use Edujugon\GoogleAds\GoogleAds;
use Google\AdsApi\AdWords\v201809\mcm\CustomerService;
use Edujugon\GoogleAds\Session\AdwordsSession;

$userRefreshCredentials = [
    'clientId' => config('google-ads.production.clientId'),
    'clientSecret' => config('google-ads.production.clientSecret'),
    'refreshToken' => config('google-ads.production.refreshToken')
];

$adWordsServices = new GoogleAds();
$session = (new AdwordsSession())->buildWithOAuth(config('google-ads.production.developerToken'),$userRefreshCredentials);

$managedCustomerService = $adWordsServices->service(CustomerService::class, $session)->getService();
$page = $managedCustomerService->getCustomers();

i get this response:

Argument 1 passed to Google\AdsApi\AdWords\AdWordsSessionBuilder::withOAuth2Credential() must implement interface Google\Auth\FetchAuthTokenInterface, array given, called in /home/glanaj/projects/neon/vendor/edujugon/laravel-google-ads/src/src/Session/AdwordsSession.php on line 90

@Edujugon
Copy link
Owner

Hi @gezimapi ,

Make sure that your userRefreshCredentials is an instance of \Google\Auth\Credentials\UserRefreshCredentials

@Edujugon
Copy link
Owner

Hope this code snippet helps:

use Edujugon\GoogleAds\Auth\OAuth2;

$oAuth = new OAuth2();

$userRefreshCredentials = $oAuth->userCredentials([
    'clientId' => 'XXX',
    'clientSecret' => 'XXX',
    'refreshToken' => 'XXX'
]);

@gezimapi
Copy link
Author

hi ,

Now it works , i have multiple MCC can I set the clientCustomerId to get only the accounts of one MCC.

Thx in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants