My bad, I now understand what you meant.

For those who is getting the same error, I forgot to set the 
LoginCustomerId property on client.config.

    public static GoogleAdsClient 
GetGoogleAdsClient(GeneralRequestWithoutCustomerClientId request)
    {
        var client = new GoogleAdsClient();

        client.Config.OAuth2Mode = 
Google.Ads.Gax.Config.OAuth2Flow.APPLICATION;
        client.Config.OAuth2Scope = GeneralConstants.SCOPE;
        client.Config.DeveloperToken = request.DeveloperToken;
        client.Config.OAuth2ClientId = request.OAuth2ClientId;
        client.Config.OAuth2ClientSecret = request.OAuth2ClientSecret;
        client.Config.OAuth2RefreshToken = request.OAuth2RefreshToken;
        client.Config.LoginCustomerId =  request.LoginCustomerId //I FORGOT 
TO SET THIS
        return client;
    }

After setting  LoginCustomerId, everything worked.

Thanks

On Thursday, March 23, 2023 at 9:10:41 AM UTC+3 Özgür Nevres wrote:

> Thanks for the answer.
>
> If the user / email address has access or is associated with the MCC / 
> manager account, you will need to specify the MCC / manager account's ID 
> without hyphens (-) as the value of the login-customer-id 
> <https://developers.google.com/google-ads/api/docs/concepts/call-structure#cid>
>  field.
>
> Yes, the user is associated with the MCC account. But, how can I specify 
> the login-customer?
> I am using the sample code provided by Google on the link below:
> https://developers.google.com/google-ads/api/samples/add-campaigns
>
> I couldn't find a login-customer-id property on these objects.
>
>
> On Wednesday, March 22, 2023 at 8:35:40 PM UTC+3 Google Ads API Forum 
> Advisor wrote:
>
>> Hello,
>>
>> Thank you for reaching out to the Google Ads API Support.
>>
>> Apparently you are getting an *AuthorizationError* 
>> <https://developers.google.com/google-ads/api/reference/rpc/v13/AuthorizationErrorEnum.AuthorizationError>:
>>  
>> USER_PERMISSION_DENIED error when trying to create a campaign. This is 
>> because the User doesn't have permission to access the customer. Please 
>> note that if you're accessing a client customer, the manager's customer id 
>> must be set in the 'login-customer-id' header. 
>>
>> To prevent this kind of error, I would suggest specifying the 
>> login-customer-id as the manager account ID without hyphens (-). That being 
>> said, you will need to ensure that the user / email address you used to 
>> generate the credentials indeed has access 
>> <https://support.google.com/google-ads/answer/9978556?visit_id=637628826037447236-382779227&rd=1>
>>  to 
>> the account in your request.
>>
>> If the user / email address has access or is associated with the MCC / 
>> manager account, you will need to specify the MCC / manager account's ID 
>> without hyphens (-) as the value of the login-customer-id 
>> <https://developers.google.com/google-ads/api/docs/concepts/call-structure#cid>
>>  field.
>>
>> Furthermore, if the issue persists, can you please provide us with the 
>> complete *request* 
>> <https://developers.google.com/google-ads/api/docs/concepts/field-service#request>
>>  and *response logs* 
>> <https://developers.google.com/google-ads/api/docs/concepts/field-service#response>
>>  generated 
>> as shown in the respective links, so we can check on our end the errors 
>> being thrown?
>>
>> If you haven't enabled logging yet, it can be enabled by navigating to 
>> the Client libraries > Your client library (ex. Java) > *Logging 
>> documentation* 
>> <https://developers.google.com/google-ads/api/docs/best-practices/logging#client_library_logging>,
>>  
>> which you can access from this link. For REST interface requests, you can 
>> enable logging via the curl command by using the -i flag. 
>>
>> You can provide it via Reply privately to the author option. If this 
>> option is not available, then send it instead on this email address 
>> googleadsa...@google.com.
>>
>> Regards,
>> [image: Google Logo] Google Ads API Team 
>>
>> ref:_00D1U1174p._5004Q2k1tex:ref
>>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 
"Google Ads API and AdWords 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/082a14bd-f4f2-46dc-a299-04f22d7e8769n%40googlegroups.com.

Reply via email to