Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps: Platform rejected your request. This I[...] site or [...] is not authorized to use this API key

Tags:

maps

embed

api

<iframe width="100%" height="427" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?q=place_id:[place_id]&key=[my_key]" allowfullscreen></iframe>

"Google Maps Platform rejected your request. This IP, site or mobile application is not authorized to use this API key. Request received from IP address xxx.xxx.xxx.xxx, with referer: https://xxx.xxx/"

In Google Dev I have enabled Maps Embed API and also Maps Static API. I have limited the key to work with my domain only, where the above code is included, like https://[asterisk].thedomain.com/[asterisk].

The map embed works and does not throw an error, when I do NOT limit the key to this single domain.

The issue is, that the key is plain readable in the code and thus I need to limit the key to my domain.

Any ideas?

Thank you.

like image 407
Thommy Tomka Avatar asked May 25 '18 22:05

Thommy Tomka


2 Answers

My site in question is delivered like https://thedomain.com/.

Google Maps Platform does make a difference between https://www.thedomain.com/ and https://thedomain.com/.

Limiting my API to https://thedomain.com/* worked for me, while https://*.thedomain.com/* does not imply * to be nothing.

like image 152
Thommy Tomka Avatar answered Oct 12 '22 00:10

Thommy Tomka


Make sure you have "Maps Embeded API" added to the key restrictions / api restriction section of the API Key you are using.

like image 45
nmdpa3 Avatar answered Oct 12 '22 01:10

nmdpa3