如何在 PERMISSION DENIED 错误时使用 OAuth2 Playground 获取 Google 帐户数据(项目、地点和所有地点评论)

发布于 2025-01-14 13:10:53 字数 2308 浏览 3 评论 0原文

案例

我希望使用 OAuth2 为内部项目获取所有 Google My Business API 地点评论。我正在使用 OAuth2 Playground 进行测试,但我无法在以下步骤中获得适当的许可

  1. :授权 API:在 API 字段输入中粘贴“https://www.googleapis.com/auth/business.manage”单击“授权 API”
  2. 让自己获得授权代码以获取访问令牌
  3. 使用 GET 方法,无需附加标头,我就能够获取有关项目的基本数据,但无法从特定位置获取。我可以列出帐户。

即使在我的项目中,我也能够实现这一点: https://developers.google .com/my-business/content/implement-oauth。虽然我能够在 OAuth2 Playground 中使用以下内容: https://developers.google .com/my-business/content/account-data。但我需要使用这个: https://developers.google.com/my -业务/内容/评论数据

响应中的错误消息:

      {
  "error": {
    "status": "PERMISSION_DENIED", 
    "message": "Google My Business API has not been used in project PROJECTCODE before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/mybusiness.googleapis.com/overview?project=PROJECTCODE then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", 
    "code": 403, 
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help", 
        "links": [
          {
            "url": "https://console.developers.google.com/apis/api/mybusiness.googleapis.com/overview?project=PROJECTCODE", 
            "description": "Google developers console API activation"
          }
        ]
      }, 
      {
        "reason": "SERVICE_DISABLED", 
        "@type": "type.googleapis.com/google.rpc.ErrorInfo", 
        "domain": "googleapis.com", 
        "metadata": {
          "consumer": "projects/PROJECTCODE", 
          "service": "mybusiness.googleapis.com"
        }
      }
    ]
  }
}

当我从响应中的链接访问项目信息后,它将显示错误:“您没有足够的权限来查看此页面”并且:

您缺少以下必需的内容权限: 项目 资源管理器.projects.get serviceusage.services.get

和 IAM 文档的链接我觉得非常令人困惑。

问题

  1. 为了从属于我正在访问的帐户的位置获取评论数据,我缺少什么?
  2. 我是否使用正确的 API 访问或方法来达到我想要的结果?
  3. 问题是否真的出在某些 IAM 权限上?如果是这样,如何设置它们来实现我的目标?

The case:

I want to get all Google My Business API place reviews using OAuth2 for internal project. I am using OAuth2 Playground for testing purposes while I am not able to get proper permission in these steps:

  1. Select & authorize APIs: pasting "https://www.googleapis.com/auth/business.manage" in the API field input & clicking "Authorize APIs"
  2. Letting myself obtain authorization code to obtain access token
  3. Using method GET, without additional headers I am able to obtain basic data about the project, but not from the particular place. I am able to list accounts.

Even in my project I was able to implement this: https://developers.google.com/my-business/content/implement-oauth. While I was able to use in OAuth2 Playground this: https://developers.google.com/my-business/content/account-data. But I need to use this: https://developers.google.com/my-business/content/review-data.

The error message in response:

      {
  "error": {
    "status": "PERMISSION_DENIED", 
    "message": "Google My Business API has not been used in project PROJECTCODE before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/mybusiness.googleapis.com/overview?project=PROJECTCODE then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", 
    "code": 403, 
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help", 
        "links": [
          {
            "url": "https://console.developers.google.com/apis/api/mybusiness.googleapis.com/overview?project=PROJECTCODE", 
            "description": "Google developers console API activation"
          }
        ]
      }, 
      {
        "reason": "SERVICE_DISABLED", 
        "@type": "type.googleapis.com/google.rpc.ErrorInfo", 
        "domain": "googleapis.com", 
        "metadata": {
          "consumer": "projects/PROJECTCODE", 
          "service": "mybusiness.googleapis.com"
        }
      }
    ]
  }
}

After I access the project info from the link from response It will show error :"You do not have sufficient permissions to view this page" and this:

You are missing the following required permissions:
Project
resourcemanager.projects.get
serviceusage.services.get

and links to the IAM docs which I find very confusing.

Questions:

  1. What am I missing in order to get review data from place belonging to the account I am accessing to?
  2. Am I using proper API access or method to reach my desired result?
  3. Could the problem be really in some IAM permissions? If so, how to set them to reach my goal?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清风不识月 2025-01-21 13:10:54

在您收到的消息中,url 对象中有一个链接

“链接”:[
{
“url”:“https://console.developers.google.com/apis/api/mybusiness.googleapis.com/overview?project=PROJECTCODE”,
"description": "Google 开发者控制台 API 激活"
}

该链接,在浏览器中打开它,您可能需要登录您的帐户,然后启用 APi。然后您应该能够运行您的代码或在游乐场中查看您想要的内容

in the message you received there is a link in url object

"links": [
{
"url": "https://console.developers.google.com/apis/api/mybusiness.googleapis.com/overview?project=PROJECTCODE",
"description": "Google developers console API activation"
}

copy that link, open it in the browser, and probably you need to sign into you account and then Enable the APi. Then you should be able to run your code or see what you want in playground

飞烟轻若梦 2025-01-21 13:10:53

请访问以下网址检查您是否有权访问“Google 我的商家”API:
https://console.cloud.google.com/apis/dashboard

与“我的”不同企业帐户管理 API、检索评论所需的 Google 我的商家 API 是私有的。


编辑:概述页面不是问题,我说的是API访问。它应该显示在已启用的 API 列表中:

启用 API


编辑 2
您缺少第 9 个 API,即原始的“Google 我的商家”API。
由于文档 (https://developers.google.com/my- Business/content/prereqs#request-access) 没有提及如何访问旧 API,如果他们仍然提供访问权限,我会尝试联系 API 支持:https://support.google.com/business/contact/api_default

Please check if you have access to the Google My Business API by visiting
https://console.cloud.google.com/apis/dashboard

Unlike the My Business Account Management API, the Google My Business API required to retrieve reviews is private.


Edit: the overview page is not the issue, I am talking about API access. It should show up in the list of enabled APIs:

Enabled APIs


Edit 2:
You are missing the 9th API, the original Google My Business API.
Since the documentation (https://developers.google.com/my-business/content/prereqs#request-access) does not mention how to get access to the old API, I would try contacting the API support if they still give out access to it: https://support.google.com/business/contact/api_default

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文