簡體   English   中英

如何在出現 PERMISSION DENIED 錯誤時使用 OAuth2 Playground 獲取 Google 帳戶數據(項目、地點和所有地點評論)

[英]How to get Google account data (project, place and all place reviews) using OAuth2 Playground while PERMISSION DENIED error

案子:

我想為內部項目使用 OAuth2 獲取所有 Google 我的商家 API 地方評論。 我正在使用 OAuth2 Playground 進行測試,但我無法在這些步驟中獲得適當的許可:

  1. Select & 授權 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-business/content/review-data

響應中的錯誤消息:

      {
  "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"
        }
      }
    ]
  }
}

在我從響應的鏈接訪問項目信息后,它將顯示錯誤:“您沒有足夠的權限查看此頁面”和這個:

您缺少以下必需權限:項目 resourcemanager.projects.get serviceusage.services.get

以及我覺得非常混亂的 IAM 文檔的鏈接。

問題:

  1. 為了從屬於我正在訪問的帳戶的地方獲取評論數據,我缺少什么?
  2. 我是否使用正確的 API 訪問或方法來達到我想要的結果?
  3. 問題真的可能出在某些 IAM 權限中嗎? 如果是這樣,如何設置它們以達到我的目標?

請通過訪問https://console.cloud.google.com/apis/dashboard 檢查您是否有權訪問 Google 我的商家 API

與我的企業帳戶管理 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

在您收到的消息中有一個鏈接 url object

"links": [ { "url": "https://console.developers.google.com/apis/api/mybusiness.googleapis.com/overview?project=PROJECTCODE", "description": "谷歌開發者控制台API激活“}

復制該鏈接,在瀏覽器中打開它,您可能需要登錄您的帳戶,然后Enable APi。然后您應該能夠運行您的代碼或在 playground 中查看您想要的內容

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM