hatzisn Expert Licensed User Longtime User Mar 28, 2018 #1 Hello everybody, I am experimenting with google geocoding. I have created a geocoding api key as described in this tutorial: https://www.b4x.com/android/forum/threads/b4x-google-geocoding-rest-api.83870/ I also restricted the geocoding api key to my android application and specifically to Google Maps Geocoding API. When I try to do reverse geocoding (coordinates to address) with the following code: Code: Copy Dim hj As HttpJob Dim sRet As String hj.Initialize("Geocoding", Me) hj.Download2("https://maps.googleapis.com/maps/api/geocode/json", _ Array As String("latlng", latitude & "," & longidude,"key","AIzaSyA-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")) I get the following json: Code: Copy { "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address xx.x.xxx.210, with empty referer", "results" : [], "status" : "REQUEST_DENIED" } What is the matter? I cannot figure out something. Any help will be highly appreciated.
Hello everybody, I am experimenting with google geocoding. I have created a geocoding api key as described in this tutorial: https://www.b4x.com/android/forum/threads/b4x-google-geocoding-rest-api.83870/ I also restricted the geocoding api key to my android application and specifically to Google Maps Geocoding API. When I try to do reverse geocoding (coordinates to address) with the following code: Code: Copy Dim hj As HttpJob Dim sRet As String hj.Initialize("Geocoding", Me) hj.Download2("https://maps.googleapis.com/maps/api/geocode/json", _ Array As String("latlng", latitude & "," & longidude,"key","AIzaSyA-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")) I get the following json: Code: Copy { "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address xx.x.xxx.210, with empty referer", "results" : [], "status" : "REQUEST_DENIED" } What is the matter? I cannot figure out something. Any help will be highly appreciated.
hatzisn Expert Licensed User Longtime User Mar 28, 2018 #2 I just scrolled down in the tutorial as seen in the first post and saw Erel's answer on restricting the API KEY. Isn't it dangerous (for one's pocket) not to restrict the api key. Isn't there any workarounds? Edit - I unrestricted the API KEY and it works. Any workarounds to restrict the api key and still work in my application? Last edited: Mar 28, 2018 Upvote 0
I just scrolled down in the tutorial as seen in the first post and saw Erel's answer on restricting the API KEY. Isn't it dangerous (for one's pocket) not to restrict the api key. Isn't there any workarounds? Edit - I unrestricted the API KEY and it works. Any workarounds to restrict the api key and still work in my application?
hatzisn Expert Licensed User Longtime User Mar 28, 2018 #3 I found a workaround. If I add a string variable in Main's activity process globals and set it to the API KEY, I can compile to realease (obfuscated) and the string variable will be obfuscated. I pass now the variable to the httpjob and get it done with the following code: Code: Copy Dim hj As HttpJob hj.Initialize("Geocoding", Module) hj.Download2("https://maps.googleapis.com/maps/api/geocode/json", _ Array As String("latlng", latitude & "," & longidude,"key", Main.geoAK)) Am I correct? Upvote 0
I found a workaround. If I add a string variable in Main's activity process globals and set it to the API KEY, I can compile to realease (obfuscated) and the string variable will be obfuscated. I pass now the variable to the httpjob and get it done with the following code: Code: Copy Dim hj As HttpJob hj.Initialize("Geocoding", Module) hj.Download2("https://maps.googleapis.com/maps/api/geocode/json", _ Array As String("latlng", latitude & "," & longidude,"key", Main.geoAK)) Am I correct?