â›”

RefererNotAllowedMapError

🏡 Home 📖 Chapter 👉 Next
⚡  GMapsBook.com is crafted by Jozef Sorocin (🟢 Book a consulting hour) and powered by:
  • g-Xperts (Google Cloud & Business Profile Partner)
 

Error explanation

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.

Likely causes

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:xyz which is purposefully excluded from the list of referrers.

Solutions

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:
1. Go to https://console.cloud.google.com/apis/credentials and click on “Edit API key”:

Already purchased? Sign in here.