USER_PERMISSION_DENIED on Get recomandation call

65 views
Skip to first unread message

emona123456

unread,
Apr 22, 2020, 9:14:53 AM4/22/20
to AdWords API and Google Ads API Forum
Greetings Ads Team!
I'm using Google Ads PHP library v3 for the first time, using these instructions here :https://github.com/googleads/google-ads-php/blob/master/README.md
I have problem with getting Recomandation, 
ApiException was thrown with message '{
    "message": "The caller does not have permission",
    "code": 7,
    "status": "PERMISSION_DENIED",
    "details": [
        {
            "@type": 0,
            "data": "type.googleapis.com\/google.ads.googleads.v3.errors.GoogleAdsFailure"
        },
        {
            "@type": 0,
            "data": [
                {
                    "errorCode": {
                        "authorizationError": "USER_PERMISSION_DENIED"
                    },
                    "message": "User doesn't have permission to access customer. Note: If you're accessing a client customer, the manager's customer id must be set in the 'login-customer-id' header. See https:\/\/developers.google.com\/google-ads\/api\/docs\/concepts\/call-structure#login-customer-id"
                }
            ]
        }
    ]
}'.

I have set the clientCustomerId , loginCustomerId  and CUSTOMER_ID 

Please help to solve this problem.

Thanks,
Emona


Google Ads API Forum Advisor Prod

unread,
Apr 22, 2020, 12:15:29 PM4/22/20
to emonah...@gmail.com, adwor...@googlegroups.com

Hi Emona,


Thanks for reaching out. The error USER_PERMISSION_DENIED usually occurs when there is no link between the manager account authenticated in the request and the client account specified in the headers. Could you please make sure that the manager account you used to authenticate the call has administrative access to the client account you are calling against? If the issue persists, could you please send me the complete request and response logs along with the client customer id and the email you used to generate the OAuth2 credentials via Reply privately to the author option?


For the PHP library logging information, you can follow the instructions here.


Thanks,
Nirmita Patel Google Ads Team



ref:_00D1U1174p._5001UaRtCQ:ref

emona hystuna

unread,
Apr 27, 2020, 4:41:18 PM4/27/20
to AdWords API and Google Ads API Forum
Hello Nirmita,

First of all thank you for the response, 

We already have credentials from the AdWords API and the code of google_ads_php.ini is as shown:

[GOOGLE_ADS]
; Required AdWords API properties. Details can be found at:
; https://developers.google.com/adwords/api/docs/guides/basic-concepts#soap_and_xml
developerToken
= "xxxxxxxxxxxxxxxxxxx"
clientCustomerId
= "774-826-5171"
loginCustomerId
= "266-371-1171"

The GetTextAdRecommendations.php code si the same as the example on php library on : https://github.com/googleads/google-ads-php/blob/master/examples/Recommendations/GetTextAdRecommendations.php

How can I check if the account manager 266-371-1171 has the administrative access for the customer_id 3617418922
this customer id is in the hierarchy of this account manager.

class GetTextAdRecommendations
{
   
private const CUSTOMER_ID = '3617418922';
   
private const PAGE_SIZE = 1000;

   
public static function main()
   
{
       
// Either pass the required parameters for this example on the command line, or insert them
       
// into the constants above.
        $options
= (new ArgumentParser())->parseCommandArguments([
           
ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT
       
]);
       
// Generate a refreshable OAuth2 credential for authentication.
        $oAuth2Credential
= (new OAuth2TokenBuilder())->fromFile('../Authentication/google_ads_php.ini')->build();

       
// Construct a Google Ads client configured from a properties file and the
       
// OAuth2 credentials above.
        $googleAdsClient
= (new GoogleAdsClientBuilder())
           
->fromFile('../Authentication/google_ads_php.ini')
           
->withOAuth2Credential($oAuth2Credential)
           
->build();
.......................


I have reply privately to the author before 2 days .

Please can you help me with this . 

Thank you 
Emona
Reply all
Reply to author
Forward
0 new messages