Google Maps Geolocation api: access not configured

I am trying to use google geolocation api on Android. I am sure I have a valid apikey for Android and I have enabled billing. However, the server returns

doman: usageLimits resonance: access not configured code: 403

Can anyone solve this problem? PS: I do not have support to support Google development. My code is below

JSONObject holder = new JSONObject(); JSONArray cellarray = new JSONArray(); JSONArray wifiarray = new JSONArray(); JSONObject cell = new JSONObject(); JSONObject wifi1 = new JSONObject(); JSONObject wifi2 = new JSONObject(); try { cell.put("cellId", cid); cell.put("locationAreaCode", lac); cell.put("mobileCountryCode", mcc); cell.put("mobileNetworkCode", mnc); cell.put("age", 0); cell.put("signalStrength", -95); cellarray.put(cell); wifi1.put("macAddress", "01:23:45:67:89:AB"); wifi1.put("signalStrength", 8); wifi1.put("age", 0); wifi1.put("signalToNoiseRatio", -65); wifi1.put("channel", 8); wifiarray.put(wifi1); wifi2.put("macAddress", "01:23:45:67:89:AC"); wifi2.put("signalStrength", 4); wifi2.put("age", 0); wifiarray.put(wifi2); holder.put("homeMobileCountryCode", mcc); holder.put("homeMobileNetworkCode", mnc); holder.put("radioType", "gsm"); holder.put("carrier", "T-Mobile"); holder.put("cellTowers", cellarray); holder.put("wifiAccessPoints", wifiarray); } catch (JSONException e) { e.printStackTrace(); } DefaultHttpClient client = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("https://www.googleapis.com/geolocation/v1/geolocate?key="+API_key); StringEntity stringEntity = null; try { stringEntity = new StringEntity(holder.toString()); stringEntity.setContentType("application/json"); Log.v("zf",stringEntity.getContentType().toString()); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } httpPost.setEntity(stringEntity); HttpResponse httpResponse = null; try { httpResponse = client.execute(httpPost); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } 
+6
source share
2 answers

Possible reason # 1: Add a sensor value to your URL, it is NOT required!

Possible Cause # 2: Did you enable the geolocation service in the API console?

Possible reason # 3: Have you set up your billing information in the API console?

0
source

The cause of the error is obvious when reading the string response:

 "code": 403, "message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed." 

Go to the Developer Console and in the "Credentials" section, add your application in the "Restriction of Use in Android Applications" section.

0
source

All Articles