双击投标管理器api授权


Doubleclick bid manager api authorization

我在使用DoubleClick Bid Manager API验证自己时遇到了麻烦我已经按照谷歌的指示设置了一个服务帐户,并使用谷歌api PHP客户端库。按照文档,我的代码看起来像这样:

require_once 'Google/autoload.php';
$client_email = 'myemail.com';
$private_key = file_get_contents('myfilename.p12');
$scopes = ['https://www.googleapis.com/auth/doubleclickbidmanager'];
$credentials = new Google_Auth_AssertionCredentials(
    $client_email,
    $scopes,
    $private_key,
);


$client = new Google_Client();
$client->setAssertionCredentials($credentials);
if ($client->getAuth()->isAccessTokenExpired()) {
    $client->getAuth()->refreshTokenWithAssertion();
}
$service =  new Google_Service_DoubleClickBidManager($client);
$response = $service->queries->listqueries();

最后一行提示错误:

致命错误:未捕获的异常'Google_Service_Exception'与消息'错误调用GET https://www.googleapis.com/doubleclickbidmanager/v1/queries:(403)你没有被授权使用DoubleClick Bid Manager API。请联系bidmanager-support@google.com

我给他们发了邮件,但我不确定是否有人在那里提供技术问题的支持。我已经重新阅读了文档,我看不出哪里出错了。如果有人经历过这个或有任何指示,他们将非常感激!!

多谢

PS我设置了我的API访问本周早些时候。再一次,我按照文档中的说明进行操作,并收到了谷歌关于设置的最后一封确认邮件,所以在这方面一切都应该很顺利

DoubleClick Bid Manager不支持服务帐户。它们使用DBM中的用户权限来定义API请求的权限,因此需要基于用户的身份验证。

您可能需要将业务帐户的用户邮箱添加到具有read/write角色的DV 360

这是我使用google api客户端库为ruby做的:

1-首先创建一个GOOGLE_APPLICATION_CREDENTIALS环境变量:

$ export GOOGLE_APPLICATION_CREDENTIALS='[Path to your client_secrets.json]

2-建立一个服务变量来连接API并为其分配授权:

scopes = 'https://www.googleapis.com/auth/doubleclickbidmanager'
authorization = Google::Auth.get_application_default(scopes)
service = Google::Apis::DoubleclickbidmanagerV1::DoubleClickBidManagerService.new
service.authorization = authorization
service.authorization.fetch_access_token!
# This line would return results from the api
service.download_line_items

请注意,.json secrets文件中的电子邮件帐户必须作为DV360上具有read/write角色的用户添加