I'm tring to add an account budget to a google-ads account, and below is my
main codes
from __future__ import absolute_import
import argparse
import sys
import os
import six
import google.ads.google_ads.client
os.environ['https_proxy'] = 'xxxxxxx'
GG_DEVELOP_TOKEN = "GG_DEVELOP_TOKEN"
credentials_dict_bv = {"token_uri": "https://oauth2.googleapis.com/token",
"token": None, "scopes": ["https://www.googleapis.com/auth/adwords",
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email", "openid"], "client_id":
"78532xxx312e4-aol074eetb5kvq46enrk4v368sq.apps.googleusercontent.com",
"refresh_token": "1/jqqFFFYHMxxABIQ5vKUHwpNRRzwDq-zED8", "client_secret":
"L3JhhpUDDDDDVd7ionYsED"}
def main(client, customer_id, billing_setup_id):
account_budget_proposal_service = client.get_service(
'AccountBudgetProposalService')
billing_setup_service = client.get_service('BillingSetupService',
version='v2')
account_budget_proposal_operation = client.get_type(
'AccountBudgetProposalOperation')
proposal = account_budget_proposal_operation.create
proposal.proposal_type = client.get_type(
'AccountBudgetProposalTypeEnum').CREATE
proposal.billing_setup.value = billing_setup_service.billing_setup_path(
customer_id, billing_setup_id)
proposal.proposed_name.value = 'Account Budget Proposal (example)'
# Specify the account budget starts immediately
proposal.proposed_start_time_type = client.get_type('TimeTypeEnum',
version='v2').NOW
# Alternatively you can specify a specific start time. Refer to the
# AccountBudgetProposal resource documentation for allowed formats.
#
# proposal.proposed_start_date_time = '2020-01-02 03:04:05'
# Specify that the budget runs forever
proposal.proposed_end_time_type = client.get_type('TimeTypeEnum',
version='v2').FOREVER
# Alternatively you can specify a specific end time. Allowed formats
are as
# above.
#
# proposal.proposed_end_date_time = '2021-01-02 03:04:05'
# Optional: set notes for the budget. These are free text and do not
effect
# budget delivery.
#
# proposal.proposed_notes = client.wrapper
# .string('Received prepayment of $0.01')
proposal.proposed_spending_limit_micros.value = 0
try:
account_budget_proposal_response = (
account_budget_proposal_service.mutate_account_budget_proposal(
customer_id, account_budget_proposal_operation))
except google.ads.google_ads.errors.GoogleAdsException as ex:
import pprint
pprint.pprint(ex)
print('Request with ID "%s" failed with status "%s" and includes
the '
'following errors:' % (ex.request_id, ex.error.code().name))
for error in ex.failure.errors:
print('\tError with message "%s".' % error.message)
if error.location:
for field_path_element in
error.location.field_path_elements:
print('\t\tOn field: %s' %
field_path_element.field_name)
sys.exit(1)
print('Created account budget proposal "%s".'
% account_budget_proposal_response.result.resource_name)
if __name__ == '__main__':
# GoogleAdsClient will read the google-ads.yaml configuration file in
the
# home directory if none is specified.
credentials =
google.oauth2.credentials.Credentials(**credentials_dict_bv)
client = google.ads.google_ads.client.GoogleAdsClient(credentials,
GG_DEVELOP_TOKEN, login_customer_id='586008752')
parser = argparse.ArgumentParser(
description='Creates an account budget proposal.')
# The following argument(s) should be provided to run the example.
parser.add_argument('-c', '--customer_id', type=six.text_type,
required=True, help='The Ads customer ID.')
parser.add_argument('-b', '--billing_setup_id', type=six.text_type,
required=True, help='The billing setup ID.')
args = parser.parse_args()
main(client, args.customer_id, args.billing_setup_id)
I'm following the example from google-ads-python lient-lib.
But I get error like :
Request made: ClientCustomerId: 9834324964, Host:
googleads.googleapis.com:443, Method:
/google.ads.googleads.v2.services.Acc
ountBudgetProposalService/MutateAccountBudgetProposal, RequestId:
5iXkX8okwYlFxvj5WFywsQ, IsFault: True, FaultMessage: No cus
tomer found for the provided customer id.
GoogleAdsException(<_Rendezvous of RPC that terminated with:
status = StatusCode.UNAUTHENTICATED
details = "Request is missing required authentication credential.
Expected OAuth 2 access token, login cookie or othe
r valid authentication credential. See
https://developers.google.com/identity/sign-in/web/devconsole-project."
debug_error_string =
"{"created":"@1568260015.365636024","description":"Error received from peer
ipv4:10.0.0.19:8118"
,"file":"src/core/lib/surface/call.cc","file_line":1052,"grpc_message":"Request
is missing required authentication credential .
Expected OAuth 2 access token, login cookie or other valid authentication
credential. See https://developers.google.com/ide
ntity/sign-in/web/devconsole-project.","grpc_status":16}"
>, <_Rendezvous of RPC that terminated with:
status = StatusCode.UNAUTHENTICATED
details = "Request is missing required authentication credential.
Expected OAuth 2 access token, login cookie or othe
r valid authentication credential. See
https://developers.google.com/identity/sign-in/web/devconsole-project."
debug_error_string =
"{"created":"@1568260015.365636024","description":"Error received from peer
ipv4:10.0.0.19:8118"
,"file":"src/core/lib/surface/call.cc","file_line":1052,"grpc_message":"Request
is missing required authentication credential .
Expected OAuth 2 access token, login cookie or other valid authentication
credential. See https://developers.google.com/ide
ntity/sign-in/web/devconsole-project.","grpc_status":16}"
>, errors {
error_code {
authentication_error: CUSTOMER_NOT_FOUND
}
message: "No customer found for the provided customer id."
}
, '5iXkX8okwYlFxvj5WFywsQ')
Request with ID "5iXkX8okwYlFxvj5WFywsQ" failed with status
"UNAUTHENTICATED" and includes the following errors:
Error with message "No customer found for the provided customer
id.".
I'm confused that I can get right result with the credentials above to
request billing-setup info, but failed with add account budget?
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 [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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/cc66a97f-057d-41be-9d0e-ce04ffe27108%40googlegroups.com.