The RefererNotAllowedMapError is an error that can occur when trying to use a Google Maps API, such as the Google Maps JavaScript API or the Google Maps Geocoding API. This error typically indicates that the website or domain that is making the API request is not on the list of allowed referrers for the API key being used.
Causes of RefererNotAllowedMaperror
- The API key being used is not associated with the correct project. In order to use a Google Maps API, you must have an API key that is associated with a project that has the appropriate permissions and access to the API.
- The website or domain making the API request is not on the list of allowed referrers for the API key. In order to use a Google Maps API, you must specify the websites or domains that are allowed to make API requests with the API key. If the website or domain making the request is not on this list, the RefererNotAllowedMapError will be triggered.
- There is an issue with the API key being used. If the API key is invalid or does not have the necessary permissions to use the API, the RefererNotAllowedMapError may be triggered.
Steps to fix the RefererNotAllowedMapError
- Click the project drop-down menu at the top of the page, and select the project that you want to modify the authorized referrers.
- Click the hamburger menu and select APIs & Services > Credentials.
- Click the name of the API key that you want to modify.
- Click the Edit button in the restriction section > In the Application restrictions section, select the HTTP referrers option.
- To allow any referrer on a specific domain, you can use a wildcard at the beginning and end of the domain name:
Example: *.example.com/*
This will allow any referrer on the https://www.example.com/ domain, such as https://www.example.com/page1, https://sub.example.com/page2, etc. to use the Google Maps API. - To allow a specific referrer, you can enter the exact URL:
Example: https://www.example.com/page1
This will allow only the specified referrer to use the Google Maps API. - To allow any referrer with a specific subdomain, you can use a wildcard at the beginning and end of the subdomain:
Example: https://maps.*.com/*
This will allow any referrer with the maps subdomain, such as https://maps.example.com/page1, https://maps.other.com/page2, etc. to use the Google Maps API. - To allow multiple referrers on a specific domain, you can use a wildcard at the beginning and end of the domain name, and separate each referrer with a comma:
Example: *example.com/*
This will allow any referrer on the https://example.com, https://example.com/page1 domain to use the Google Maps API. - To allow a range of referrers, you can use a wildcard at the beginning and end of the domain name, and specify a range of subdomains using a hyphen:
Example: https://maps-*.example.com/*
This will allow any referrer with a subdomain that starts with maps- on the https://maps-sitename.example.com/, https://maps-sitename-one.example.com/page1 domain to use the Google Maps API.
- To allow any referrer on a specific domain, you can use a wildcard at the beginning and end of the domain name:
- In the Referrers field, enter the list of allowed referrers for the API key. You can use the wildcard character (*) to match multiple referrers.
- Click the “Save” button to update the application restrictions for the API key
Conclusion
RefererNotAllowedMapError occurs when the referrer is not on the list of allowed referrers for the API key. To solve this error, you can check the application restrictions for the API key and make sure that the referrer’s domain is on the list of allowed referrers, or you can ensure that the correct API key is being used by the referrer.