Google Cloud Translate API & Referer Restriction Issue

Hello Dear Community !

I have a frustrating issue with the Google Cloud Translate API.

I set up correctly the restriction of the API key to some domains including *.example.com/* 

I launch the script on the URL https://www.example.com/translate and i have the following message :

 

 

Message: {
  "error": {
    "code": 403,
    "message": "Requests from referer \u003cempty\u003e are blocked.",
    "errors": [
      {
        "message": "Requests from referer \u003cempty\u003e are blocked.",
        "domain": "global",
        "reason": "forbidden"
      }
    ],
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "API_KEY_HTTP_REFERRER_BLOCKED",
        "domain": "googleapis.com",
        "metadata": {
          "consumer": "projects/464292577200",
          "service": "translate.googleapis.com"
        }
      }
    ]
  }
}

 

 

 

When i remove the restriction, everything works, but i need the restriction to avoid misuse/abuse.
I tried to change the restriction to *.example.com, www.example.com, example.com/*, even with the dedicated URL, but nothing works, always the same error message.

Do you have any ideas or any ways to investigate better this issue ? How i can know the referrer Google get when i launch my request ? 

It's driving me crazy !

Thanks a lot and happy new year to everybody !!!

1 6 3,787
6 REPLIES 6

The API key being used seems to have some type of HTTP restriction [1], and needs to be properly referred.

You should recreate a new API key, without an IP referrer, as it doesn't seem related to either roles/permissions.

You could also try adding the full URL, including "https" as mentioned in the examples [2].

Here are some Stack Overflow examples [3][4].

[1] https://cloud.google.com/docs/authentication/api-keys#adding_http_restrictions
[2] https://cloud.google.com/docs/authentication/api-keys#:~:text=Allow%20any%20subdomain,least%20two%20....
[3] https://stackoverflow.com/questions/70013973/error-when-using-iap-external-identities-sign-in-page
[4] https://stackoverflow.com/questions/69803590/error-api-key-http-referrer-blocked-ocurred-at-using-yo...

Thanks for your reply, i created a new API Key with no restriction => It worked
Then i added a basic restriction : *.domain.com/* and it stopped to work with the same error message as before. 
I tried to add the exact full URL with https included, and same error also.

I don't know what to do. In the meantime, we implemented another translate solution from your main competitor and it worked in 5 minutes...

So it's a bit depressing, especially when we speak about billions of caracters to translate each month with money for you (Google) at the end. 

The last time we had an issue with Google API it was for the Maps API, hopefully there was a a chat support included and it was an issue from Google' side regarding country restriction linked to our account.  It was solved in few minutes by your technical staff...

But for the translation API we feel a bit lonely to fix that...

Same issue still no fix to this.

 

MyCCPay

I have a key google translate message like this but don't know how to handle it, please help.


{ "error": { "code": 403, "message": "Requests from referer \u003cempty\u003e are blocked.", "errors": [ { "message": "Requests from referer \u003cempty\u003e are blocked.", "domain": "global", "reason": "forbidden" } ], "status": "PERMISSION_DENIED", "details": [ { "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "API_KEY_HTTP_REFERRER_BLOCKED", "domain": "googleapis.com", "metadata": { "service": "translate.googleapis.com", "consumer": "projects/281599394813" } } ] } }

Same problem here.
How to fix it?

Same problem here.