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

Document electron's implicit use of Google services #7306

Closed
nikola opened this issue Sep 22, 2016 · 13 comments
Closed

Document electron's implicit use of Google services #7306

nikola opened this issue Sep 22, 2016 · 13 comments

Comments

@nikola
Copy link

nikola commented Sep 22, 2016

  • Electron version: 1.4.0
  • Operating system: any

The docs say:

Electron includes a hardcoded API key for making requests to Google's geocoding webservice.

When do these requests happen, and for which exact purpose? This should be documented.

Also, there should be an environment flag to disable these kind of requests altogether.

@zeke
Copy link
Contributor

zeke commented Sep 22, 2016

Good idea. Would love to know more about all the APIs that require network activity.

The geocoding webservice is hit when your app uses navigator.geolocation. There are other Chrome APIs that will make external requests (Text to Speech?), but none of these requests are made unless you explicitly write your app to make use of them.

@nikola
Copy link
Author

nikola commented Sep 22, 2016

Where in the codebase is this actually performed? Looking at the Google Geolocation API surface it seems a lot of system information needs to be gathered and provided to the web service for this to work - is this actually implemented in electron?

A quick test in a sample app shows that electron returns an empty GeoLocation from navigator.geolocation.

@zeke
Copy link
Contributor

zeke commented Sep 22, 2016

An HTTP debugging proxy might help answer that question. We could examine the request payload.

Here's one written in Electron! https://github.com/james-proxy/james

@deepak1556
Copy link
Member

@nikola Electron only provides the api key for the geolocation service, the actual implementation is taken care by chromium , same goes for speech api.

@nikola
Copy link
Author

nikola commented Sep 24, 2016

@deepak1556 Can you point me to an example where accessing navigator.geolocation actually performs such a request? Because in my testing so far, both in the Electron API Demos app and in a sample app, no request to Google's Geolocation API is triggered when accessing navigator.geolocation, no network activity, no logs anywhere. So one might suspect that even though Chromium provides that facility, it's not functional from within electron.

@zeke
Copy link
Contributor

zeke commented Sep 24, 2016

@nikola sorry for my lack of clarity above. navigator.geolocation is just an object with method properties like getCurrentPosition and watchPosition. Try this:

navigator.geolocation.getCurrentPosition(
  console.log.bind(console),
  console.error.bind(console)
)

@nikola
Copy link
Author

nikola commented Sep 24, 2016

@zeke Thanks, that's now returning a 403, probably because electron's quota are exceeded. Using my own key, I can confirm that it works on this side, too.

@DenisCarriere
Copy link

Note

Solution was found after writing this comment, this comment is simply used as reference/archive.


@nikola You've got the geolocation.getCurrentPosition() to work in Electron? I keep getting this error 403 error:

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

I'm simply adding this to my index.html and trying to get any response from success().

<script>
navigator.geolocation.getCurrentPosition(
  success => console.log(success),
  error => console.log(error)
);
</script>

Solution - Add Google API Key

After adding enabling GeoLocation and adding the Google API to my main.js before the window is created everything worked.

https://console.developers.google.com/apis/api/geolocation.googleapis.com/

main.js

process.env.GOOGLE_API_KEY = "<GOOGLE API KEY>"

CC: #8918 #8754 #8212

@hollenberry
Copy link

@DenisCarriere

Thank you for posting this! You helped me solve a tricky bug on a personal project ❤️ .

@DenisCarriere
Copy link

@hollenberry 👍 Welcome, it took me forever to solve this issue, hence the in-depth explanations. In the end this was a very simple fix (however it's kinda annoying that you need to enter a Google API key for it to work).

@damianobarbati
Copy link

But is the Google API request mandatory? Any other way to use native Chromium geolocation without making external calls and having to keep track of used quota?
Or its use is intended just when calling navigator.geolocation.getCurrentPosition from the main process thus not having a real Chromium running (which means that navigator.geolocation.getCurrentPosition from a renderer process does not use the Google API request)?

@dhuang612
Copy link

so is this PR basically an added note that to get geolocation working, they need to use the google api?

@erickzhao
Copy link
Member

Going to close this, since the hard-coded API key was removed in #15478. The fix at #7306 (comment) is now documented at https://github.com/electron/electron/blob/master/docs/api/environment-variables.md.

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

No branches or pull requests

9 participants