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

[Bug]: navigator.geolocation.getCurrentPosition() on windows 10 #36252

Closed
3 tasks done
bonjourjoel opened this issue Nov 4, 2022 · 7 comments
Closed
3 tasks done

[Bug]: navigator.geolocation.getCurrentPosition() on windows 10 #36252

bonjourjoel opened this issue Nov 4, 2022 · 7 comments
Labels

Comments

@bonjourjoel
Copy link

bonjourjoel commented Nov 4, 2022

Preflight Checklist

Electron Version

21.2.1

What operating system are you using?

Windows

Operating System Version

Windows 10 version 22H2

What arch are you using?

x64

Last Known Working Electron version

NA

Expected Behavior

I'm trying to make navigator.geolocation.getCurrentPosition() work. It works on any browser on the same machine, including chrome.

Actual Behavior

I get this error: Network location provider at 'https://www.googleapis.com/' : Returned error code 403.

I don't need any google api. I'm using the standard javascript api to get geolocation position. I'm not querying google maps or anything.

Testcase Gist URL

https://gist.github.com/bonjourjoel/4b8953ac3fe9b61dcf8d085b052044fb

Additional Information

Running electron on windows 10 on the gist html file bug-geo.html will reproduce the issue: $> electron bug-geo.html

Precision 1: I do NOT use any google api, and i don't need any paid google api key. This code is standalone and not related to google in any way. This code should work and it's the example copied from the official mdn doc: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition

Precision 2: This is not related to https. You can reproduce this on any page: Open any page with electron, including a secure page like https://google.com and open the dev tools, and copy/paste the script in the console. You will get the same error.

@bonjourjoel
Copy link
Author

I'm not sure i understand but it seems that electron is not free as advertised. And i would have to pay per quantity of instructions executed?

How much does it cost for each call to geolocation api? And is there a pricing table of all the payed features of electron?

I guess a call to console.log() is free? But what about getUserMedia() for example? Is it a payed service?

@Prinzhorn
Copy link
Contributor

Someone from the Electron team can probably explain it better, but the data for geolocation.getCurrentPosition() has to come from somewhere. Since your desktop PC doesn't have an actual GPS chip, in contrast to your phone. Electron is based on Chromium and Chromium falls back to using Google APIs to approximate your location based on your IP (in general geolocation on desktop doesn't make much sense anyway). That's why it's making a call to the Google API. It's the same API that is used when you're calling geolocation.getCurrentPosition() inside Chromium. And Electron doesn't ship with Google APIs keys for these API, but Chromium does. But from the last link I've posted you can see that even in Chromium you can run into this issue because the keys that Google ships with Chromium have a limited quota as well (I assume people also abuse them for free API access).

If you really need to get an approximate location for a desktop users, there are other APIs as well you could use. But again, I don't see a point of using these APIs on a desktop without an actual GPS device.

@bonjourjoel
Copy link
Author

Yes, there is a point. If this api exists on javascript with desktop architecture, there is a reason. I am actually using it in a real project, which i would like to convert to an installable desktop app. I can see that electron is not able to do this since it's way too expensive for me. I will search another solution and i regret to have lost time studying electron. I wish there were a pricing table somewhere to look at before spending time on an electron project.

Thanks for the answers.

@Prinzhorn
Copy link
Contributor

Prinzhorn commented Nov 4, 2022

I think one of us is misunderstanding, I'm sure someone from the Electron team can clarify.

This has nothing to do with Electron and these services are usually not free (or of low quality). Search for "ip geolocation", you'll find countless of databases and providers other than Google. Again, this is only a fallback if the location cannot be acquired through more accurate means such as GPS or Wifi. There's simply no other technical way to get a user's location if no other sources are available. And if it has to fall back to IP geolocation, the data is mostly useless anyway (depending on the use-case) and can be incredibly inaccurate. So you'd have to handle an error of getCurrentPosition() anyway and provide a manual way to enter a location. So nothing really changed regarding your requirements.

@bonjourjoel
Copy link
Author

This is so not true. You have one use case in mind and you make conclusions based on it. You don't think about the infinite possibilities of computer programs. I do have one app using this already, and i need this in my interface.
And i understand the reasons behind this pricing, but i regret to not be informed before losing time on studying electron. If something has a cost, i would like to know it before i start using it. Etiquette requires there should be a pricing table clearly labeled as such on the front page of the project.

Thanks for the explanations.

@ralyodio
Copy link

You are both right, its frustrating (and I don't even think the GOOGLE_API_KEY hack works anymore anyway, didn't for me).

I guess ipinfo.io api is the best way to go.

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

No branches or pull requests

3 participants