Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

OPERATION_NOT_PERMITTED_FOR_CONTEXT HELP!!!

48 views
Skip to first unread message

zikuo su

unread,
May 6, 2025, 5:15:17 AMMay 6
to Google Ads API and AdWords API Forum
Hello developers:
Recently, there have been frequent errors when creating customer accounts on my Google Ads API:

2025-05-06T08:53:00.397Z
details = "Request contains an invalid argument."
2025-05-06T08:53:00.397Z
debug_error_string = "UNKNOWN:Error received from peer ipv4:172.253.115.95:443 {grpc_message:"Request contains an invalid argument.", grpc_status:3, created_time:"2025-05-06T08:53:00.394049374+00:00"}"
2025-05-06T08:53:00.397Z
>, errors {
2025-05-06T08:53:00.397Z
error_code {
2025-05-06T08:53:00.397Z
context_error: OPERATION_NOT_PERMITTED_FOR_CONTEXT
2025-05-06T08:53:00.397Z
}
2025-05-06T08:53:00.397Z
message: "The operation is not allowed for the given context."
2025-05-06T08:53:00.397Z
}
2025-05-06T08:53:00.397Z
request_id: "_SECq70Mb5DBKfbdwGozfw"
2025-05-06T08:53:00.397Z
, '_SECq70Mb5DBKfbdwGozfw')
2025-05-06T08:53:00.397Z
During handling of the above exception, another exception occurred:
2025-05-06T08:53:00.397Z
Traceback (most recent call last):
2025-05-06T08:53:00.397Z
File "/var/lang/lib/python3.11/logging/__init__.py", line 1110, in emit
2025-05-06T08:53:00.397Z
msg = self.format(record)
2025-05-06T08:53:00.397Z
^^^^^^^^^^^^^^^^^^^
2025-05-06T08:53:00.397Z
File "/var/lang/lib/python3.11/logging/__init__.py", line 953, in format
2025-05-06T08:53:00.397Z
return fmt.format(record)
2025-05-06T08:53:00.397Z
^^^^^^^^^^^^^^^^^^
2025-05-06T08:53:00.397Z
File "/var/lang/lib/python3.11/logging/__init__.py", line 687, in format
2025-05-06T08:53:00.397Z
record.message = record.getMessage()
2025-05-06T08:53:00.397Z
^^^^^^^^^^^^^^^^^^^
2025-05-06T08:53:00.397Z
File "/var/lang/lib/python3.11/logging/__init__.py", line 377, in getMessage
2025-05-06T08:53:00.397Z
msg = msg % self.args
2025-05-06T08:53:00.397Z
~~~~^~~~~~~~~~~
2025-05-06T08:53:00.397Z
TypeError: not all arguments converted during string formatting
2025-05-06T08:53:00.397Z
Call stack:
2025-05-06T08:53:00.398Z
File "/var/runtime/bootstrap.py", line 63, in <module>
2025-05-06T08:53:00.398Z
main()
2025-05-06T08:53:00.398Z
File "/var/runtime/bootstrap.py", line 60, in main
2025-05-06T08:53:00.398Z
awslambdaricmain.main([os.environ["LAMBDA_TASK_ROOT"], os.environ["_HANDLER"]])
2025-05-06T08:53:00.398Z
File "/var/lang/lib/python3.11/site-packages/awslambdaric/__main__.py", line 21, in main
2025-05-06T08:53:00.398Z
bootstrap.run(app_root, handler, lambda_runtime_api_addr)
2025-05-06T08:53:00.398Z
File "/var/lang/lib/python3.11/site-packages/awslambdaric/bootstrap.py", line 521, in run
2025-05-06T08:53:00.398Z
handle_event_request(
2025-05-06T08:53:00.398Z
File "/var/lang/lib/python3.11/site-packages/awslambdaric/bootstrap.py", line 175, in handle_event_request
2025-05-06T08:53:00.398Z
response = request_handler(event, lambda_context)
2025-05-06T08:53:00.398Z
File "/var/task/main/repeater.py", line 150, in lambda_handler
2025-05-06T08:53:00.398Z
Repeater(event).distribute()
2025-05-06T08:53:00.398Z
File "/var/task/main/repeater.py", line 53, in distribute
2025-05-06T08:53:00.398Z
self.sns_func()
2025-05-06T08:53:00.398Z
File "/var/task/main/repeater.py", line 85, in sns_func
2025-05-06T08:53:00.398Z
self.customer_run(data)
2025-05-06T08:53:00.398Z
File "/var/task/main/repeater.py", line 98, in customer_run
2025-05-06T08:53:00.398Z
dispatch.run(_)
2025-05-06T08:53:00.398Z
File "/var/task/modules/eros/jobs/dispatcher.py", line 32, in run
2025-05-06T08:53:00.398Z
Executor(manager_class, executor_class).execute()
2025-05-06T08:53:00.398Z
File "/var/task/modules/eros/jobs/executor.py", line 48, in execute
2025-05-06T08:53:00.398Z
self._execute_with_exceptions()
2025-05-06T08:53:00.398Z
File "/var/task/modules/eros/jobs/executor.py", line 26, in _execute_with_exceptions
2025-05-06T08:53:00.398Z
suc_batch_tasks, fai_batch_tasks = self._run_with_exceptions()
2025-05-06T08:53:00.398Z
File "/var/task/modules/eros/jobs/executor.py", line 22, in _run_with_exceptions
2025-05-06T08:53:00.398Z
suc_batch_tasks, fai_batch_tasks = jobs_executor.run(self._get_jobs())
2025-05-06T08:53:00.398Z
File "/var/task/jobs/erp_basic_task_executor.py", line 132, in run
2025-05-06T08:53:00.398Z
return TaskExecutor.run(sources, VirtualBatchExecutor(), self)
2025-05-06T08:53:00.398Z
File "/var/task/modules/eros/jobs/task_executor.py", line 25, in run
2025-05-06T08:53:00.398Z
batch_target.execute(tasks)
2025-05-06T08:53:00.398Z
File "/var/task/modules/eros/jobs/batch_executor.py", line 34, in execute
2025-05-06T08:53:00.398Z
super().execute(VirtualBatch, callers)
2025-05-06T08:53:00.398Z
File "/var/task/modules/eros/jobs/batch_executor.py", line 17, in execute
2025-05-06T08:53:00.398Z
api_batch.execute()
2025-05-06T08:53:00.398Z
File "/var/task/modules/eros/jobs/virtual_batch.py", line 13, in execute
2025-05-06T08:53:00.398Z
rsp = caller.execute()
2025-05-06T08:53:00.398Z
File "/var/task/basic_insights/erp_google_open_account/erp_google_open_account_tasks_v1.py", line 35, in execute
2025-05-06T08:53:00.398Z
data = GoogleOpenAccount(source.id).run()
2025-05-06T08:53:00.398Z
File "/var/task/basic_insights/erp_google_open_account/erp_google_open_account_tasks_v1.py", line 99, in run
2025-05-06T08:53:00.398Z
api_result_list = self.create(self.all_open_account)
2025-05-06T08:53:00.398Z
File "/var/task/basic_insights/erp_google_open_account/erp_google_open_account_tasks_v1.py", line 145, in create
2025-05-06T08:53:00.398Z
status, api_result = api_class.create(
2025-05-06T08:53:00.398Z
File "/var/task/utils/channels/google/__init__.py", line 70, in create
2025-05-06T08:53:00.398Z
account, err = self.CustomerAccountClient.create(descriptive_name, currency_code, time_zone)
2025-05-06T08:53:00.398Z
File "/var/task/utils/channels/google/customers.py", line 48, in create
2025-05-06T08:53:00.398Z
Log.error("CustomerUserAccessInvitation.add ads exception:{}", e)
2025-05-06T08:53:00.398Z
Message: 'CustomerUserAccessInvitation.add ads exception:{}'
2025-05-06T08:53:00.398Z
Arguments: (GoogleAdsException(<_InactiveRpcError of RPC that terminated with:
2025-05-06T08:53:00.398Z
status = StatusCode.INVALID_ARGUMENT
2025-05-06T08:53:00.398Z
details = "Request contains an invalid argument."
2025-05-06T08:53:00.398Z
debug_error_string = "UNKNOWN:Error received from peer ipv4:172.253.115.95:443 {grpc_message:"Request contains an invalid argument.", grpc_status:3, created_time:"2025-05-06T08:53:00.394049374+00:00"}"
2025-05-06T08:53:00.398Z
>, <_InactiveRpcError of RPC that terminated with:
2025-05-06T08:53:00.398Z
status = StatusCode.INVALID_ARGUMENT
2025-05-06T08:53:00.398Z
details = "Request contains an invalid argument."
2025-05-06T08:53:00.398Z
debug_error_string = "UNKNOWN:Error received from peer ipv4:172.253.115.95:443 {grpc_message:"Request contains an invalid argument.", grpc_status:3, created_time:"2025-05-06T08:53:00.394049374+00:00"}"
2025-05-06T08:53:00.398Z
>, errors {
2025-05-06T08:53:00.398Z
error_code {
2025-05-06T08:53:00.398Z
context_error: OPERATION_NOT_PERMITTED_FOR_CONTEXT
2025-05-06T08:53:00.398Z
}
2025-05-06T08:53:00.398Z
message: "The operation is not allowed for the given context."
2025-05-06T08:53:00.398Z
}
2025-05-06T08:53:00.398Z
request_id: "_SECq70Mb5DBKfbdwGozfw"
2025-05-06T08:53:00.398Z
, '_SECq70Mb5DBKfbdwGozfw'),)

It has been normal before, and the probability of this situation occurring is about 10% to 20%

Google Ads API Forum Advisor

unread,
May 6, 2025, 8:09:14 AMMay 6
to zik...@gmail.com, adwor...@googlegroups.com

Hi,

Thank you for reaching out to the Google Ads API support team

I have raised your concern with the rest of our team and one of my teammates will reach out to you once we have an update. Meanwhile, your patience is appreciated. 

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-05-06 12:08:13Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01qVyIw:ref" (ADR-00304053)



Google Ads API Forum Advisor

unread,
May 6, 2025, 8:25:01 AMMay 6
to adwor...@googlegroups.com, zik...@gmail.com
Hi:

This was just escalated to me. The error OPERATION_NOT_PERMITTED_FOR_CONTEXT usually indicates that the action you're trying to perform isn't allowed for the type of account or the specific context in which you're operating. Given that you're trying to create customer client accounts under a manager account, here are some things to check:
 
  1. Confirm CustomerService.CreateCustomerClient Usage: Confirm you are indeed trying to use the CustomerService and its CreateCustomerClient method for creating new client accounts, not GoogleAdsService.Mutate (which is for operations within an existing account).
  2. Verify Ensure your API client configuration (e.g., google-ads.yaml) has the login_customer_id set to the ID of the Manager Account (255-136-6266).
  3. Verify OAuth2 Credentials:
    • Are the OAuth2 credentials (client ID, client secret, refresh token) generated by a user who has admin access to the MCC 255-136-6266?
    • If you are unsure, you should regenerate the refresh token using the "Log in with Google" flow with an admin user of that MCC.
  4. Check User Permissions in MCC UI: The user who authorized the OAuth2 credentials needs to have "Admin" rights (or equivalent to create accounts) within the MCC 255-136-6266. you can check this under "Tools & Settings" -> "Access and security" in the Google Ads UI for the MCC.
  5. Simplified Test Case: Try the most basic CustomerService.CreateCustomerClient call with only the required fields (descriptive name, currency code, time zone) to isolate the issue.
  6. Request Payload: If the issue persists after checking the above, request the exact request body (or the Python code constructing the CreateCustomerClientRequest) you are sending that results in the _SECq70Mb5DBKfbdwGozfw request ID. The UNKNOWN and INVALID_ARGUMENT errors often point to issues in the request payload itself.
Since we have successfully created client accounts with your test manager account, the issue is very likely specific to your authentication, permissions, or the way you are constructing your API request for client creation. The OPERATION_NOT_PERMITTED_FOR_CONTEXT strongly suggests an authentication/authorization mismatch for the intended operation.
 

Thanks,
 
Google Logo
Bob Hancock
Google Ads API Team


Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-05-06 12:23:58Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01qVyIw:ref" (ADR-00304053)



Reply all
Reply to author
Forward
0 new messages