Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser API key does not work with referer

I'm making website which use Google translate API. I have setup Browser API key But the problem is that Browser API key works only if I leave empty field Accept requests from these HTTP referrers (web sites) .

If I put there *.mydomain.com/* I’m getting error:

There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.

What am I doing wrong?

like image 494
Szmulik Avatar asked Sep 16 '15 10:09

Szmulik


2 Answers

Just to keep note, I had this error today, and it happens because of the Key Type. You need to use a Server Key instead of a Browser Key.

To create one, go to Google Console (https://console.developers.google.com/), and API Manager > Credentials.

like image 96
Dimas Pante Avatar answered Oct 26 '22 15:10

Dimas Pante


Go to https://console.developers.google.com, in credential tab, edit api key you are using and change api restriction from "browser" to "none" or "server". note: if your are using server restriction that you need to add correct server path.

https://i.stack.imgur.com/CzhUn.png

like image 44
Hemin Avatar answered Oct 26 '22 16:10

Hemin