Thank you for your continued support.

I figures this out this morning.

Once I pull the account I want to view,

I use 

$user->SetClientCustomerId( $account_id );

I can get it from the accountId of the campaign object for example.




Also I realized, my initial problem with USER_DENIED was that since I didnt 
update the Auth.ini, I was logging in ok but the logged in user was trying 
to access the Account of the MCC who owns the API access.

So instead of the User accessing their data, they were trying to access the 
MCCs data.

I had to remove the clientId from the Auth.ini and that made it work.



I just wanted to post this, I figure someone may find it helpful for 
pulling accounts under and MCC.


function getAccounts(AdWordsUser $user)
{
 
        $managedCustomerService =
   $user->GetService('ManagedCustomerService', ADWORDS_VERSION);
 
 $selector = new Selector();
  $selector->fields = array('CustomerId','Name');
  $selector->ordering[] = new OrderBy('Name', 'ASCENDING');

 
 
 $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
 
// $page = $managedCustomerService->get($selector);
 
  
 
 $accounts = array();
 
      do {
// Make the get request.
$page = $managedCustomerService->get($selector);
  // Display results.
if (isset($page->entries)) {
   
  return $page->entries;
  
} else {
return array();
}

// Advance the paging index.
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
  } while ($page->totalNumEntries > $selector->paging->startIndex);
 }





On Tuesday, December 10, 2013 8:52:35 PM UTC-5, Paul Matthews (AdWords API 
Team) wrote:
>
> The clientCustomerId is the identifier for the account you wish to access. 
> You need to specify this in the AdWordsUser to access that account.
>
> The OAuth2 layer is purely to permit access, the clientCustomerId 
> specifies<https://code.google.com/p/google-api-adwords-php/source/browse/src/Google/Api/Ads/AdWords/Lib/AdWordsUser.php#99>which
>  sub account you're accessing.
>
> For more information on this please read the 
> README<https://code.google.com/p/google-api-adwords-php/source/browse/README#56>
> .
>
> Regards,
>
> - Paul, AdWords API Team.
>
> On Tuesday, 10 December 2013 12:58:26 UTC-8, Christian Gibbs wrote:
>>
>> By the way, your video helped. Because I didnt know there was a new 
>> Auth.ini file.
>>
>> Now Im getting this error.
>>
>> The client customer ID must be specified for report downloads.'
>>
>>
>> When I run the campaign service, I can do that and view all the campaigns 
>> but I cannot download the reports because I dont have the clientCustomerId.
>>
>>
>>
>> How is this suppose to work when using OAuth2?
>>
>>
>> I have a refresh token. Everything is working ok, when just viewing the 
>> campaigns but not for downloading reports. The Id is required.
>>
>>
>> Any idea?
>>
>>
>> Thanks
>>
>>
>>
>>
>>
>> On Tuesday, December 10, 2013 2:50:53 PM UTC-5, Christian Gibbs wrote:
>>>
>>> I GOT IT!!!!!!!!!
>>>
>>>
>>>
>>> After getting the ?code=   from the URL
>>>
>>>
>>> $url = "https://accounts.google.com/o/oauth2/token";;
>>>     $params = array(
>>> "code" => $authCode,
>>> "client_id" => $clientId,
>>> "client_secret" => $clientSecret,
>>> "redirect_uri" => $callbackUrl,
>>> "grant_type" => "authorization_code"
>>>     );
>>>  
>>>     $curl = curl_init();
>>>     curl_setopt($curl, CURLOPT_URL, $url);
>>>     curl_setopt($curl, CURLOPT_HEADER, false);
>>>     curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
>>>     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
>>>     curl_setopt($curl, CURLOPT_POST, true);
>>>     curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
>>>     curl_setopt($curl, CURLOPT_ENCODING, "");
>>>     $curlData = curl_exec($curl);
>>>     curl_close($curl);
>>>  $result = json_decode ($curlData);
>>> print_r( $result );
>>>  
>>>  $access_token = $result->access_token;
>>>
>>>
>>>
>>> $user = new AdWordsUser();
>>>  $user->SetOAuth2Info(array(
>>>     "client_id" => $clientId,
>>>     "client_secret" => $clientSecret,
>>>     "access_token" => $access_token,
>>>     "refresh_token" => ""
>>> ));
>>>
>>> I save the Auth Info and I was able to pull the other account data!
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Tuesday, December 10, 2013 11:33:29 AM UTC-5, Christian Gibbs wrote:
>>>>
>>>> The OAuth login works fine, when I login myself. I can pull the data. 
>>>> But when I use another google account of mine I get the authorization 
>>>> error.
>>>>
>>>> I need to achieve this. Please dont say this is the result because the 
>>>> account is unlinked. Please give me some direction on how to achieve this.
>>>>
>>>> One of your colleague is saying it is possible. 
>>>>
>>>>
>>>> On Tuesday, December 10, 2013 11:30:26 AM UTC-5, Christian Gibbs wrote:
>>>>>
>>>>> I updated everything over like you said with the OAuthHandler class.
>>>>>
>>>>> One of your staff said this. 
>>>>>
>>>>>
>>>>> Takeshi Hagikura (AdWords API Team)[image: Google Employee] 
>>>>> Nov 12
>>>>> Hi Bikram,
>>>>>
>>>>> If the accounts are not linked to your MCC, you need to get a separate 
>>>>> access token (and a refresh token) for each client account. 
>>>>> In that case, I think an installed application mechanism is not 
>>>>> practical because it requires manual process for each account. 
>>>>>
>>>>> You can use the web application 
>>>>> flow<https://developers.google.com/accounts/docs/OAuth2#webserver> by 
>>>>> preparing a web server that doesn't require manual process in your side 
>>>>> when a client grants your application access to their data. 
>>>>>
>>>>>
>>>>>
>>>>> Please give some insight in regards to accessing unlinked accounts. 
>>>>> This is what I am interested in. Please understand my goal.
>>>>>
>>>>> I need this to be able to authorize Adwords account users, that have 
>>>>> nothing to do with my MCC account.
>>>>>
>>>>>
>>>>>
>>>>> https://groups.google.com/forum/#!msg/adwords-api/8vhiFuU-4is/Y-UprxyBXQgJ
>>>>>
>>>>>
>>>>>
>>>>> On Tuesday, December 10, 2013 10:44:13 AM UTC-5, Paul Matthews 
>>>>> (AdWords API Team) wrote:
>>>>>>
>>>>>> Hi Christian,
>>>>>>
>>>>>> When you say you've done many changes, what kind of changes? Are you 
>>>>>> able to get authentication working as per the 
>>>>>> screencast<https://www.youtube.com/watch?v=KetKPhxY4Js>? 
>>>>>> Using the video is the easiest way to get the authentication working.
>>>>>>
>>>>>> The USER_PERMISSION_DENIED is served when you're attempting to access an 
>>>>>> unlinked account 
>>>>>> <https://developers.google.com/adwords/api/docs/reference/v201309/AdGroupService.AuthorizationError#reason>.
>>>>>>
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> - Paul, AdWords API Team.
>>>>>>
>>>>>>
>>>>>> On Thursday, 14 November 2013 08:38:30 UTC-8, Christian Gibbs wrote:
>>>>>>>
>>>>>>> I keep getting, AuthorizationError.USER_PERMISSION_DENIED
>>>>>>>
>>>>>>> What is the point of them logging in, if you need to get their 
>>>>>>> permission again.
>>>>>>>
>>>>>>> I want anyone to be able to access their adwords account, via our 
>>>>>>> platform. Like so many other apps and websites do.
>>>>>>>
>>>>>>> I have refresh tokens and I can access my own account just fine, but 
>>>>>>> with other account logins, I get this error 
>>>>>>> AuthorizationError.USER_PERMISSION_DENIED
>>>>>>>
>>>>>>> It make the app pointless, if I have to manually add ever client in 
>>>>>>> and then allow them to login.
>>>>>>>
>>>>>>> So many apps allow this kind of access. How is it possible?
>>>>>>>
>>>>>>> I made a google app, that has a google login authorization prompt 
>>>>>>> screen, then once the user consents, the login is successful but I can 
>>>>>>> not 
>>>>>>> access their data.
>>>>>>>
>>>>>>> Im stuck in a circle and its driving me crazy. Please HELP!
>>>>>>>
>>>>>>>
>>>>>>>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to