I know that place API requires server key to use but I am using place SDK for android. I am using restricted Android API key (Restricted using package name and SHA1) but it is giving me below error:
This IP, site or mobile application is not authorized to use this API key. Request received from IP address 203.122.438.42, with empty referer
For reference, I am pasting my code below:
public PlacesSearchResponse fetch(com.google.maps.model.LatLng location) {
PlacesSearchResponse request = new PlacesSearchResponse();
GeoApiContext context = new GeoApiContext.Builder()
.apiKey(BuildConfig.MAPS_API_KEY)
.build();
try {
request = PlacesApi.nearbySearchQuery(context, location)
.radius(5000)
.keyword("Shivam")
.type(PlaceType.BAKERY)
.await();
} catch (Exception e) {
e.printStackTrace();
} finally {
return request;
//Log.d("==", "=====" + request.results[0].name);
}
}
Dependency I am using:
> //To get near by locations
> implementation 'com.google.maps:google-maps-services:0.18.0'
> implementation 'com.squareup.okhttp3:okhttp:4.9.0'