Google Maps Static API key restriction change

Google Maps Static API key restriction change

Google is notifying Google Maps Platform customers of a security change to the Maps Static API, Street View Static API, and Street View Metadata API. If your application displays Google imagery through ThinkGeo, check how your API key is restricted before October 2, 2027.

What Google is changing

From Google’s notice:

Currently, requests to the Maps Static API, Street View Static API, and Street View Metadata API with empty or missing Referrer headers may, in some cases, bypass configured API key security restrictions. To enhance security and ensure API key restrictions are enforced consistently across the platform, this bypassing behavior will be deprecated as of October 2, 2026, and is planned to be decommissioned (that is, strictly enforced) on October 2, 2027.

Google validates a key’s Websites restriction against the Referer header of the request. A browser writes that header; a desktop application, a service, or a native mobile application does not send it at all. Today a missing header can pass anyway. After October 2, 2027 it is validated strictly, and a request that does not satisfy the key’s restrictions fails with a 403 and a broken image.

In other words: if your key carries an HTTP referrer restriction and your application is not a browser, that key has been working only because of the behavior Google is removing.

Which ThinkGeo classes are affected

These call the Google Maps Static API:

  • GoogleMapsStaticOverlay (WPF, WinForms, Android, iOS)
  • GoogleMapsStaticAsyncLayer (ThinkGeo.Core)
  • GoogleMapsOverlay and GoogleMapsAsyncLayer, the obsolete names for the two above

These are not affected:

  • GoogleMapTilesOverlay and GoogleMapTilesAsyncLayer. They use the Google Map Tiles API, which is not part of this change.

How to check whether this affects you

  1. Open the Google Cloud console and go to Google Maps Platform, then Keys & Credentials.
  2. Open the API key your application uses and look at Application restrictions.
  3. If it is set to Websites, and the application using that key is a desktop application, a service, or a mobile application, you are affected.

If it is set to None or to IP addresses, this change does not affect you.

What to do

Restrict the key by IP address

Use this when:

  • The application runs behind a fixed outbound IP address, such as a corporate network or your own server.

This is the strongest option that requires no code change. A source IP address is observed by Google, not declared by the caller, so it cannot be supplied by someone who only has your key.

In the Google Cloud console, set Application restrictions to IP addresses and enter the outbound addresses or CIDR ranges your deployment uses.

Put the key behind your own server

Use this when:

  • The application is installed on many machines, and you can run a server component.

The key and the URL signing secret stay on your server, and the application requests map images from your own endpoint. This is the only option that keeps the credential off the end user’s machine.

Have each end user supply their own API key

Use this when:

  • The application is installed on many machines and you do not want to run a server component.

Each installation uses its own Google Maps Platform key, entered by the user, and each user’s usage is billed to their own account. Any key that ships inside a desktop application can be extracted from it; giving each user their own key limits what a leaked key can cost.

Supply the Referer header yourself

Use this when:

  • You need the application to keep working now and will choose one of the options above later.

The SendingHttpRequest event on the overlay and on the layer exposes the outgoing request before it is sent, so the header can be supplied there. No new API is required:

// WPF and WinForms
googleMapsStaticOverlay.SendingHttpRequest += (s, e) =>
    e.HttpRequestMessage.Headers.Referrer = new Uri("https://www.your-site.com/");
// On the Core layer directly
googleMapsStaticAsyncLayer.SendingHttpRequest += (s, e) =>
    e.HttpRequestMessage.Headers.Referrer = new Uri("https://www.your-site.com/");

The same event is available on the Android and iOS GoogleMapsStaticOverlay.

This does not interfere with URL signing: a Google signature covers the path and query string, not the request headers.

Two things that are easy to confuse

A URL signing secret does not satisfy a key restriction. Signing and application restrictions are separate mechanisms. If the key keeps its Websites restriction and the application sends no Referer header, the request still fails after October 2, 2027, signed or not. Signing limits what can be done with a key that has leaked; it does not decide whether the key is allowed to be used.

Supplying the Referer header keeps the key working but protects nothing. The application writes that header itself, so anyone holding the key can write the same value, and the allowed referrer is a public domain name rather than a secret. Treat it as a way to buy time, not as the fix.

Seeing what Google actually returned

The ReceivedHttpResponse event reports the response before the SDK interprets it, which is the quickest way to read Google’s own explanation of a rejection:

googleMapsStaticOverlay.ReceivedHttpResponse += (s, e) =>
{
    if (!e.ResponseMessage.IsSuccessStatusCode)
        System.Diagnostics.Debug.WriteLine(e.ResponseMessage.StatusCode);
};

ThinkGeo SDK updates

Two changes are included since 15.0.0-beta205:

  • A rejected request now says why. A failed image or tile request used to surface only The HTTP request failed with status code: Forbidden. The text the server sent is now kept alongside the status code, so a key misconfiguration explains itself. GoogleMapsStaticOverlay uses DrawingExceptionMode.DrawException by default, so that text appears on the map. This applies to the WMS, XYZ, and WMTS layers as well.

  • Documentation. GoogleMapsStaticOverlay and GoogleMapsStaticAsyncLayer now describe which key restrictions suit them, and point at both the stopgap above and the options that actually resolve it.

Google references

If you are not sure which option fits your deployment, reply with how your application is distributed and we will tell you which one to use.