1

My request to google healthcare API is not working from OAuth 2.0 playground using refresh token option. I am getting "status": "PERMISSION_DENIED". The requested API has been enabled for many days. Here's the Request and Response details.

    POST 
    /v1alpha2/projects/<project_id>/locations/<location>/datasets? 
    datasetId=<dataset_id> HTTP/1.1
    Host: healthcare.googleapis.com
    Content-length: 0
    Content-type: application/json
    Authorization: Bearer 
    HTTP/1.1 403 Forbidden
    Content-length: 767
    X-xss-protection: 0
    X-content-type-options: nosniff
    Transfer-encoding: chunked
    Vary: Origin, X-Origin, Referer
    Server: ESF
    -content-encoding: gzip
    Cache-control: private
    Date: Fri, 12 Jul 2019 17:57:39 GMT
    X-frame-options: SAMEORIGIN
    Alt-svc: quic=":443"; ma=2592000; v="46,43,39"
    Content-type: application/json; charset=UTF-8
    {
    "error": {
"status": "PERMISSION_DENIED", 
"message": "Cloud Healthcare API has not been used in project <project_id> before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/healthcare.googleapis.com/overview?project=<project_ud> 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/healthcare.googleapis.com/overview?project=<project_id>", 
        "description": "Google developers console API activation"
      }
    ]
  }
]

} }

Joe Corkery
  • 2,564
  • 3
  • 18
  • 26
sanjayk
  • 33
  • 3
  • You are accessing the "Alpha" APIs. Have you requested Google to add your project to the API Whitelist? If not, use the "Beta" APIs. – John Hanley Jul 12 '19 at 18:54
  • @JohnHanley Yes, I did try the POST API request with "v1beta1" and getting same error msg. Another thing I noticed is response is referring to project id=34********49, which is not at all in my list of Projects. – sanjayk Jul 13 '19 at 16:18
  • Your project id looks like `Project Number`. Execute this command to see a list of your projects `gcloud projects list`. This will show you the Project Numbers also. Keep in mind that the APIs between Alpha and Beta are usually different which requires different interfaces. – John Hanley Jul 13 '19 at 17:03
  • I think Tlaquetzal's answer is correct. Review his document link. Another note, I do not recommend using "Alpha" APIs unless you know what you are doing and understand that there will be service failures and bugs (API and underlying service). – John Hanley Jul 13 '19 at 17:06
  • gcloud projects list is not returning project id that I mentioned. – sanjayk Jul 13 '19 at 18:16
  • I have actually been trying beta1 API but now confused since I am seeing only Alpha2 API reference in Cloud Healthcare Authorized APIs on developers.google.com – sanjayk Jul 13 '19 at 18:23
  • Without details, I can only guess. Edit your question with specifics so we can help. – John Hanley Jul 13 '19 at 19:04

1 Answers1

0

You are using the Alpha endpoint for the Healthcare API, which has been decomissioned by Google. You can see how to make the transition for the Beta API in here: https://cloud.google.com/healthcare/docs/how-tos/transition-guide.

Also note that in addition to the change in the Request URL

/v1beta1/projects/<project_id>/locations/<location>/datasets

the response now is a long-running operation: https://cloud.google.com/healthcare/docs/reference/rest/v1beta1/projects.locations.datasets.operations

Tlaquetzal
  • 2,760
  • 1
  • 12
  • 18
  • 1
    I had used Project Name instead of Project Id in my POST request. The issue is resolved after fixing that and using the v1beta1 API. – sanjayk Jul 14 '19 at 00:51