我正在尝试访问 dbm api,我正在使用服务帐户验证 url 请在下面找到示例代码
from oauth2client.service_account import ServiceAccountCredentials
from apiclient.discovery import build
from httplib2 import Http
scopes =['https://www.googleapis.com/auth/doubleclickbidmanager']
credentials = ServiceAccountCredentials.from_json_keyfile_name(
'path/to/key/.jsonfile', scopes=scopes)
http_auth = credentials.authorize(Http())
body={}
dbm = build('doubleclickbidmanager', 'v1', http=http_auth)
print dbm
request = dbm.lineitems().downloadlineitems(body=body).execute()
print request
如果我使用oauth
机制来验证 url 代码运行正常,因为我不想要用户交互,我需要服务器到服务器机制,所以我使用了服务帐户
我尝试过的步骤:
我已经创建了服务帐户并下载了json
密钥文件并在代码中使用,但是当我尝试运行我的代码时,它会引发以下错误:
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/doubleclickbidmanager/v1/lineitems/downloadlineitems?alt=json returned "You are not authorized to use DoubleClick Bid Manager API. Please contact dbm-support@google.com.">
请帮助,提前谢谢。