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

Use separate Google API key for GeoCoding requests #1158

Open
samwata opened this issue Nov 20, 2019 · 9 comments · May be fixed by enketo/enketo-express#541
Open

Use separate Google API key for GeoCoding requests #1158

samwata opened this issue Nov 20, 2019 · 9 comments · May be fixed by enketo/enketo-express#541
Labels
bug Something isn't working help wanted Likely a good issue for a contributor

Comments

@samwata
Copy link

samwata commented Nov 20, 2019

I have noticed that when you search a location when collecting geopoint, geotrace or geoshape to a specific location it does not work on odk.enke.to and enketo.ona.io but it works on ee.kobotoolbox.org.
Is there a configuration we need to change to enable this search function on enketo.ona.io?

You can use this form to test
date_testing.xlsx

@MartijnR
Copy link
Member

MartijnR commented Nov 20, 2019

Hi Sam,

Thanks for reporting this. There is a setting but I'll have to look what's going on (Google Cloud API issue or Enketo bug). It's also not working on https://enke.to/::widgets, I noticed. It's supposed to work if a valid Google API key is used and GeoCoding is enabled in (Ona'a) Google Cloud API account.

@MartijnR MartijnR added the bug Something isn't working label Nov 20, 2019
@MartijnR
Copy link
Member

MartijnR commented Nov 20, 2019

  • check enketo-core - no bug
  • check enketo-express - no bug
  • fix odk.enke.to
  • fix enke.to

@MartijnR
Copy link
Member

MartijnR commented Nov 20, 2019

Looks like API keys should have IP restrictions instead of referrer (domain) restrictions. Must have been a recent enforcement change on Google's side. Unfortunately, IP restrictions wouldn't work for client-side requests straight to Google Cloud.

{
   "error_message" : "API keys with referer restrictions cannot be used with this API.",
   "results" : [],
   "status" : "REQUEST_DENIED"
}

https://developers.google.com/maps/faq#browser-keys-blocked-error

@MartijnR
Copy link
Member

MartijnR commented Nov 20, 2019

Solutions:

  1. unrestricted API key
  2. separate (IP-restricted) Google API key for geocoding (not shared with maps) && make geocoding calls on server instead
  3. use google maps geocoding - but disadvantage is that the maps script is not required if the installation does not use Google maps layers

For now I have chosen option 1 on my servers. I think option 2 is the way to go, but will require an enketo configuration change (and slight redesign ideally) which can be painful for Enketo installers.

@MartijnR MartijnR changed the title Search function not working on geolocation questions Use separate Google API key for GeoCoding requests Nov 20, 2019
@green3g
Copy link

green3g commented Feb 12, 2021

separate (IP-restricted) Google API key for geocoding (not shared with maps) && make geocoding calls on server instead

This seems like the way to go - rather than requiring another string of dependencies in the client side. It would allow enketo to switch geocoder providers on the back-end as well without having to change the enketo frontend. For instance if someone wanted to use mapbox.

@MartijnR
Copy link
Member

I think it is currently no longer possible to get maps and geocoding both working in an Enketo installation (1 or the other), so this has become urgent.

@MartijnR MartijnR added the help wanted Likely a good issue for a contributor label Mar 16, 2021
@green3g
Copy link

green3g commented Mar 16, 2021

I'm happy to make a pull request - just trying to get the dev environment set up. We're seeing the same issue.

I'd like to make a generic geocoding service that could be swapped out with any provider if possible. I currently use Mapbox - for example.

I could see it being configured like this for example:

// config.json 

geocoder: {
    provider: 'mapbox',
    apiKey: 'xxxx'
}
//config.json
geocoder: {
    provider: 'google',
    apiKey: 'xxxx',
}

@MartijnR
Copy link
Member

MartijnR commented Mar 16, 2021

I like that. Thanks in advance!

I guess, you'll be adding specific code for the supported providers to request and parse the response of each. MapBox and Google seem great to support out-of-the box.

Some changes will be required in Enketo-Core as well (in the geo widget). It's okay if geoCoding doesn't really work in Enketo Core, as long as we can provide some mock response (as returned by Enketo Express) to test it.

@green3g
Copy link

green3g commented Mar 23, 2023

I've updated the MR's for both enketo core and enketo - definitely no rush on checking them out but let me know if there's any changes that would be helpful!

@lognaturel lognaturel transferred this issue from enketo/enketo-express Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Likely a good issue for a contributor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants