googleads / googleads-python-lib

The Python client library for Google's Ads APIs
Apache License 2.0
681 stars 974 forks source link

Order Service: Create order throws permission denied error on a Test Network #406

Closed wtubog closed 5 years ago

wtubog commented 5 years ago

I created a Test Network using a Service Account that is linked to a Production Network and I just followed the steps described on the AdManager API documentation

However, when I try to create an Order it throws this error:

Error summary: {'faultMessage': '[PermissionError.PERMISSION_DENIED @ ]', 'requestId': 'a921dca6ce635c81332adbce49e1ab21', 'responseTime': '230', 'serviceName':
 'OrderService', 'methodName': 'createOrders'}
Traceback (most recent call last):
  File "/home/user/.virtualenvs/dfp-playground/lib/python3.6/site-packages/googleads/common.py", line 1382, in MakeSoapRequest
    *packed_args, _soapheaders=soap_headers)['body']['rval']
  File "/home/user/.virtualenvs/dfp-playground/lib/python3.6/site-packages/zeep/proxy.py", line 42, in __call__
    self._op_name, args, kwargs)
  File "/home/user/.virtualenvs/dfp-playground/lib/python3.6/site-packages/zeep/wsdl/bindings/soap.py", line 132, in send
    return self.process_reply(client, operation_obj, response)
  File "/home/user/.virtualenvs/dfp-playground/lib/python3.6/site-packages/zeep/wsdl/bindings/soap.py", line 194, in process_reply
    return self.process_error(doc, operation)
  File "/home/user/.virtualenvs/dfp-playground/lib/python3.6/site-packages/zeep/wsdl/bindings/soap.py", line 299, in process_error
    detail=fault_node.find('detail'))
zeep.exceptions.Fault: [PermissionError.PERMISSION_DENIED @ ]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "create-order.py", line 53, in <module>
    main(ad_manager_client)
  File "create-order.py", line 42, in main
    orders = order_service.createOrders(orders)
  File "/home/user/.virtualenvs/dfp-playground/lib/python3.6/site-packages/googleads/common.py", line 1394, in MakeSoapRequest
    e.detail, errors=error_list, message=e.message)
googleads.errors.GoogleAdsServerFault: [PermissionError.PERMISSION_DENIED @ ]

Here's the exact script I'm using to create the Order

# Import appropriate modules from the client library.
from googleads import ad_manager

def main(client):
    # Initialize appropriate service.
    order_service = client.GetService('OrderService', version='v201905')
    # Create order objects.

    # These user IDs are created using the sample create user script in this repo.
    orders = [{
        'name': 'DEV_MyTestOrder',
        'advertiserId': 4742743639,
        'salespersonId': 245419083,
        'traffickerId': 245452306
    }]

    # Add orders.
    orders = order_service.createOrders(orders)

    # Display results.
    for order in orders:
        print('Order with id "%s" and name "%s" was created.'
              % (order['id'], order['name']))

if __name__ == '__main__':
    # Initialize client object.
    ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage()
    main(ad_manager_client)

When I try to execute the same script on the Production Network (switching the User IDs with actual user IDs on our AdManager) it successfully creates the Order

What do you think am I missing on my Test Network setup?

Thanks in advance!

christopherseeley commented 5 years ago

If you just created the test network, you probably need to add an additional Administrator user (not the service account which doesn't have UI access) and complete the initial setup in the UI as that user. This page calls has a callout with more context: https://developers.google.com/ad-manager/api/environments