预期<文档开始>,但发现<scalar> google-ads.yaml文件错误Python 3

时间:2019-08-13 09:01:06

标签: python python-3.x yaml

我正在尝试使用其快速入门文档设置基本的google ads api调用。

我一直在尝试加载并运行google-ads.yaml文件,但我一直收到错误消息-仍然可以找到。

由于我正在使用参考文档,所以不太确定该从哪里去。

-# OAuth2 configuration
- 
#
-# The below configuration parameters are used to authenticate using the       
#
-# recommended OAuth2 flow. For more information on authenticating with 
OAuth2 #
-# see: https://developers.google.com/google-ads/api/docs/oauth/overview       
#
- 
#
developer_token: -------------
client_id: --------------------
client_secret: -----------
refresh_token: ----------------------

-# Login customer ID configuration
- 
#
-# Required for manager accounts only: Specify the login customer ID used 
to   #
-# authenticate API calls. This will be the customer ID of the 
authenticated   #
-# manager account. It should be set without dashes, for example: 
1234567890   #
-# instead of 123-456-7890. You can also specify this later in code if 
your    #
-# application uses multiple manager account + OAuth pairs.                    
#
- 
#
login_customer_id: -----------------

-# Service Account configuration
-
#
-# To authenticate with a service account add the appropriate values to 
the    #
-# below configuration parameters and remove the four OAuth credentials 
above. #
-# The "path_to_private_key_file" value should be a path to your local 
 private #
-# key json file, and "delegated_account" should be the email address that 
is  #
-# being used to impersonate the credentials making requests. for more         
#
-# information on service accounts, see:                                       
#
-# https://developers.google.com/google-ads/api/docs/oauth/service- 
accounts    #
-
#
-# path_to_private_key_file: INSERT_PATH_TO_JSON_KEY_FILE_HERE
-# delegated_account: INSERT_DOMAIN_WIDE_DELEGATION_ACCOUNT

# Logging configuration
#
# Below you may specify the logging configuration. This will be provided 
as   #
# an input to logging.config.dictConfig. Use the "level" block under the 
root #
# logger configuration to adjust the logging level. Note in the "format"      
#
# field that log messages are truncated to 5000 characters by default. You    
#
# can change this to any length by removing the ".5000" portion or 
changing   #
# it to a different number.                                                   
#
# 
# logging:
  # version: 1
  # disable_existing_loggers: False
  # formatters:
    # default_fmt:
      # format: '[%(asctime)s - %(levelname)s] %(message).5000s'
      # datefmt: '%Y-%m-%d %H:%M:%S'
  # handlers:
    # default_handler:
      # class: logging.StreamHandler
      # formatter: default_fmt
  # loggers:
    # "":
      # handlers: [default_handler]
      # level: INFO

如果有人有更好的参考点来快速入门google ads api,我将不胜感激。

Google提供的某些参考文档似乎已过时。

1 个答案:

答案 0 :(得分:0)

您是否看过一些示例google-ads.yaml文件或YAML规范? 后者明确指出,注释必须与其他标记之间用空格字符分隔。所以你的

# OAuth2 configuration
第一行的

不是注释,因为它没有与序列项指示符(-)分开。

您在谷歌搜索google-ads.yaml +引用时获得的示例是在顶层具有映射的文件,而您的示例是单个标量字符串(由于octothorp / hash之前没有空格) 。即使已更正注释,您的根级别也将是一个序列,第一项为null / None

也许您应该看看this