⛔ RefererNotAllowedMapError
As we discussed in 🔑 Protecting the API key(s) , key restriction is a security best practice .
Each API key can be restricted to a list of referrers (also called “ origins ” or simply “ websites ”).
If the key is used on a website that isn't on this list, Google Maps responds with a RefererNotAllowedMapError.
You are likely:
- Using an API key you don't own (e.g. when copy-pasting code from StackOverflow snippets.)
- Running Google Maps from a (sub)domain (e.g.
demo.gmapsbook.com) or a sub-page (e.g.gmapsbook.com/abd/xyz.html) which aren't matching the referrer patters. - Using a Production API key on
localhost:xyzwhich is purposefully excluded from the list of referrers.
If you don't have access to the Google Cloud Console, contact your site administrator or coworker responsible for Maps.
If you do have access to the Cloud Console:
- Go to https://console.cloud.google.com/apis/credentials and click on “Edit API key”: