googlemaps / js-api-loader

Load the Google Maps JavaScript API script dynamically.
Apache License 2.0
351 stars 64 forks source link

Inform about bad keys #376

Open jpoehnelt opened 3 years ago

jpoehnelt commented 3 years ago

Not sure what the implementation should look like. But it would be useful to know if they key is valid or not and allow a different code path in the application.

eegli commented 3 years ago

Same issue here.

As per the docs:

// Promise
loader
  .load()
  .then((google) => {
    new google.maps.Map(document.getElementById("map"), mapOptions);
  })
  .catch(e => {
    // do something
  });

I'd usually expect that errors from "bad keys" can be caught here. I need such validation logic as I'm letting my users input their own keys for testing purposes.

Is there even a way to validate maps api keys? I have not found anything in the docs.

jpoehnelt commented 3 years ago

@eegli see #395

sgurin commented 1 year ago

Is any news? @wangela

usefulthink commented 1 week ago

This can be implemented in client-code using the window.gm_authFailure callback.

Since the key-validation happens at an unknown time while using the API, it is not possible to include this information in the response to the load() or importLibrary calls. In a future version, we will consider making possible errors available via events or other loader-properties.