Causes of RefererNotAllowedMaperror
The RefererNotAllowedMapError can be attributed to a few key reasons:
- Incorrect API Key Association: The API key in use might not be correctly associated with the appropriate project. To leverage a Google Maps API, the API key must be linked to a project that possesses the necessary permissions and access for utilizing the specific API.
- Unauthorized Referrers: When making an API request, it’s vital to specify the list of permitted websites or domains that can utilize the API key. If the requesting website or domain isn’t included in this list of allowed referrers, the RefererNotAllowedMapError will be triggered as a security measure.
- API Key Issues: In cases where the API key lacks the essential permissions or is invalid, the RefererNotAllowedMapError may be encountered. It’s crucial to ensure that the API key is properly configured with the required authorizations to utilize the desired API functionality.
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 Key Restrictions section, select the Websites 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:
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:
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:
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:
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.
- Example: *.example.com/*
- In the Add Website field, enter the list of allowed websites for the API key. You can use the wildcard character (*) to match multiple referrers.
- Click the “Save” button to update the Key restrictions for the API key.
The RefererNotAllowedMapError arises from a specific cause: the referrer’s absence on the list of authorized referrers for the API key. To effectively address this error and restore proper functionality, consider the following steps:
- Review Application Restrictions: Ensure that the API key being used has appropriate application restrictions configured. Double-check that the domain of the referrer making the API request is explicitly listed within the allowed referrers.
- Use the Correct API Key: Verify that the correct API key is being utilized by the referrer. Confirm that the API key has the necessary permissions and is accurately associated with the intended project.
By implementing these measures, you can resolve the RefererNotAllowedMapError, ensuring seamless communication with the Google Maps API while maintaining security and access control.