【问题标题】:Cant authenticate to Doubleclick bid manager Api using a service account无法使用服务帐户向 Doubleclick bid manager Api 进行身份验证
【发布时间】:2018-03-21 05:07:27
【问题描述】:

我写了一些代码来连接google api Doubleclick bid manager

我在https://console.cloud.google.com/apis/credentials? 下载client_secrets.json,然后运行一些类似的代码

require 'google/apis/doubleclickbidmanager_v1'
require 'google/api_client/client_secrets'
service = Google::Apis::DoubleclickbidmanagerV1::DoubleClickBidManagerService.new
service.authorization = Google::Auth.get_application_default(['https://www.googleapis.com/auth/doubleclickbidmanager'])
service.download_line_items

它会响应一些错误,例如:

发送 HTTP 帖子 https://www.googleapis.com/doubleclickbidmanager/v1/lineitems/downloadlineitems? 403 #https://www.googleapis.com/doubleclickbidmanager/v1/lineitems/downloadlineitems == 403(354字节)1091ms> 捕获错误未授权ApiAccess:您无权使用 DoubleClick Bid Manager API。请联系 dbm-support@google.com。 错误 - #

Google::Apis::ClientError:未授权ApiAccess:您无权使用 DoubleClick Bid Manager API。请联系 dbm-support@google.com。 当我在https://developers.google.com/apis-explorer 运行api 时,它也返回"You are not authorized to use DoubleClick Bid Manager API. Please contact dbm-support@google.com." 有人知道这个错误,请检查并帮助我

【问题讨论】:

    标签: ruby google-api google-oauth google-api-client double-click


    【解决方案1】:

    当您的应用程序请求私有数据时,该请求必须由有权访问该数据的经过身份验证的用户授权。您的应用程序向 Google DoubleClick Bid Manager API 发送的每个请求都必须包含授权令牌。该令牌还会向 Google 识别您的应用程序。

    这就是错误的含义

    “您无权使用 DoubleClick Bid Manager API。

    确保在请求用户身份验证时包含以下范围。

    https://www.googleapis.com/auth/doubleclickbidmanager

    更多信息可以在here 找到,这里有关于如何使用ruby 的文档,您需要为您的 api 更改示例,因为这是用于日历的。

    关于服务帐户的注意事项。

    服务帐号必须经过预授权才能正常工作。对于 Google 云端硬盘,您可以使用服务帐户电子邮件地址并与它共享您的 Google 云端硬盘上的文件夹。基本上,您与服务帐户共享数据,授予其访问数据的权限。并非所有 google api 都支持服务帐户身份验证。 Youtube api、Doubleclick 和 blogger 我认为 addence 或 adWords 也是少数不支持服务帐户身份验证的,因为如果用户不响应共享请求,就无法与用户共享数据。

    【讨论】:

    • 我按照上一个指南 Service accounts ``` scopes = 'googleapis.com/auth/doubleclickbidmanager' service = Google::Apis::DoubleclickbidmanagerV1::DoubleClickBidManagerService.new service.authorization = Google::Auth.get_application_default (范围) service.download_line_items ``` 但它仍然是同样的错误 PS:我从 https://console.cloud.google.com/apis/credentials 下载 client_secrets.json
    • 双击api不支持服务账号认证,需要使用oauth2认证。如此处所述developers.google.com/bid-manager/how-tos/authorizing
    • @DalmTo:感谢您提供的信息。那么有没有办法将 DBM API 与服务器到服务器流一起使用?我需要验证并直接调用 Google API。在这种情况下没有最终用户:(
    • 好吧,如果你想访问某人的数据,你将不得不向拥有数据的用户进行身份验证,这样就有一个最终用户。
    • @DalmTo:你是对的。抱歉我的解释不好。我想要做的是访问我的数据或其他用户(我有他的谷歌用户名和密码)的数据。并且没有网络功能。只需从我的服务器直接调用 google API。我想知道这是否可能?谢谢。
    猜你喜欢
    • 1970-01-01
    • 2013-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-25
    • 2021-10-18
    • 2020-06-24
    相关资源
    最近更新 更多