Skip to main content

How can I resolve Google Maps API key errors and configure it correctly for my store locator?

How to Resolve Google Maps API Key Errors and Configure It Correctly for Your Store Locator

Google Maps API key errors can disrupt the functionality of your store locator. This guide explains common errors, their causes, and step-by-step solutions to ensure your API key is configured correctly.

Common Errors and Their Causes

1. API Keys with Referrer Restrictions Cannot Be Used with This API

This error occurs when an API key restricted by HTTP referrers (intended for client-side use) is used for server-side web services like Geocoding or Directions. Server-side APIs require IP address–restricted keys.

2. RefererNotAllowedMapError

This error indicates that your API key’s HTTP referrer restrictions do not include the domain where the map is loading.

3. Import Stopped: Google Maps Key Restrictions Blocked the Process

This error occurs when the allowed domains list for your API key does not include the domains used by the app or site.

4. This API Project Is Not Authorized to Use This API or REQUEST_DENIED

These errors indicate that required APIs are not enabled, or billing is inactive for the Google Cloud project associated with your API key.

Step-by-Step Troubleshooting Guide

Fixing HTTP Referrer Restrictions

  1. Open Google Cloud Console.

  2. Navigate to APIs & Services > Credentials.

  3. Select your API key.

  4. Under Key restrictions, choose HTTP referrers (web sites).

  5. Add your site’s domain(s) as authorized referrers (e.g., https://yourdomain.com/*).

  6. Save changes and reload your store locator.

Fixing Server-Side API Key Restrictions

  1. Open Google Cloud Console.

  2. Navigate to APIs & Services > Credentials.

  3. Select your API key.

  4. Under Key restrictions, choose IP addresses.

  5. Add the IP addresses of your server(s).

  6. Save changes and retry the operation.

Enabling Required APIs

  1. Open Google Cloud Console.

  2. Navigate to APIs & Services > Library.

  3. Enable the following APIs: - Directions API - Geocoding API - Geolocation API - Maps JavaScript API - Places API

  4. Ensure billing is active for the project.

Resolving Unrestricted API Key Warnings

  1. Use separate API keys for client-side and server-side operations.

  2. Secure the keys with proper application and API restrictions.

  3. Monitor usage to prevent unauthorized access.

Best Practices for API Key Management

  • Use separate API keys for client-side and server-side operations.

  • Regularly review and update key restrictions to match your app’s requirements.

  • Enable only the APIs you need and ensure billing is active.

  • Monitor API usage in Google Cloud Console to detect unauthorized access.

Frequently Asked Questions

What URL Should I Use to Restrict My API Key to My Website?

Restrict the API key to your website’s domain using a wildcard path. For example: https://yourdomain.com/*. This ensures the key only works when called from pages on your site.

Why Did I Receive an Unrestricted API Key Warning After a Bulk Store Upload?

Google sends warnings when API keys are not properly restricted. Bulk operations can trigger these warnings due to active use across client- and server-side requests. Secure the key with proper restrictions to mitigate risks.

What Should I Check If the Store Locator Map Isn’t Loading?

  1. Confirm the API key is entered and saved in your app settings.

  2. Check for errors in your browser’s Developer Tools > Console.

  3. Enable required APIs and ensure billing is active in Google Cloud Console.

  4. Reload your site to test.

By following these steps and best practices, you can resolve common Google Maps API key errors and ensure your store locator functions smoothly.

Did this answer your question?