Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapsLoader.status shows LoaderStatus.SUCCESS when incorrect API_KEY was provided or maps were not loaded correctly #851

Closed
andylacko opened this issue Jun 11, 2024 · 1 comment

Comments

@andylacko
Copy link

Steps to reproduce

  • change API_KEY to something silly
  • console.log({status: mapsLoader.status})
  1. it is 1 as LoaderStatus.LOADING
  2. it changes to LoaderStatus.SUCCESS

even if wrong API_KEY was provided

I can not get the information whether the maps fully loaded or there was an error ( MissingKeyMapError )

@andylacko andylacko added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jun 11, 2024
@usefulthink usefulthink removed type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. triage me I really want to be triaged. labels Jun 11, 2024
@usefulthink
Copy link
Contributor

That the API itself can be successfully loaded with an invalid API key is somewhat by design.

The reason for this is that validation of the key will happen after the API has been loaded (I'm not 100% sure, but I think it will only run the check once you start using the API by e.g. loading a map or creating a service object). This is because the key can be configured to only be allowed to use the geocoding-API for example, so loading a map with that key will result in an error. Another reason is that the key might be restricted to certain paths within the site and that information cannot be determined on the server.

The only thing you can do is define a global function window.gm_authFailure that will get called if the API detects an authentication problem with the key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants