Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.4.9 - 403 Forbidden: the client returns an empty response instead of throwing an error #397

Open
marco-merola-ef opened this issue Oct 30, 2024 · 2 comments

Comments

@marco-merola-ef
Copy link

marco-merola-ef commented Oct 30, 2024

HTTP/1.1 403 Forbidden

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

When gmaps api returns this error, the client IRoutesMatrixApi doesn't throw any exception and simply returns an empty RoutesMatrixResponse instance.
Is there a way to instrument the client to fail when the response is not 200?
How do I retrieve the list of errors?

@vivet
Copy link
Owner

vivet commented Oct 31, 2024

As far as I can see in the code, it does throw exception on Status PERMISSION_DENIED. I tested it and for me it throws.
Can you send post the code you are using?

@marco-merola-ef
Copy link
Author

marco-merola-ef commented Oct 31, 2024

I confirm. It doesn't throw any exception in this specific case.
I am using v5.4.9

POST https://routes.googleapis.com/distanceMatrix/v2:computeRouteMatrix HTTP/1.1
Host: routes.googleapis.com
X-Goog-Api-Key: ?
X-Goog-FieldMask: *
Content-Type: text/plain; charset=utf-8
Content-Length: 1183

{"travelMode":"DRIVE","languageCode":"en","regionCode":"US","extraComputations":[],"origins":[{"waypoint":{"address":"My Address Washington DC"}}],"destinations":[{"waypoint":{"address":"My Address 2 Washington DC"}},{"waypoint":{"address":"My Address 3 Washington DC"}}]}
HTTP/1.1 403 Forbidden
Vary: X-Origin
Vary: Referer
Content-Type: application/json; charset=UTF-8
Date: Thu, 31 Oct 2024 16:46:14 GMT
Server: scaffolding on HTTPServer2
Cache-Control: private
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Server-Timing: l2gfet4t7; dur=42
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Accept-Ranges: none
Vary: Origin,Accept-Encoding
Content-Length: 1027

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

@marco-merola-ef marco-merola-ef changed the title 403 Forbidden: the client returns an empty response instead of throwing an error 5.4.9 - 403 Forbidden: the client returns an empty response instead of throwing an error Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants