Open miroslavskela opened 3 years ago
I'm facing the same issue
I found this in stackoverflow: https://stackoverflow.com/a/56417713
Same here!
same
MapViewDirections Error: Error on GMAPS route request: This IP, site or mobile application is not authorized to use this API key. Request received from IP address ****************, with empty referer
I'm getting this warning in metro. I'm using an API key that's restricted to iOS apps with the bundle ids for my project. In light of what @chramos referenced in the SO post, how would you recommend we move forward @bramus?
ANY update on this facing same issue !
As @chramos mentioned this is due to the directions API being a web service. You can see a table here of the restriction options for each service.
If you have a restricted API key, it wont work if you hit it from a native app. Google expects you to hit it from a backend server. You'll need to create your own API that your app can call. That API will need to then make the request to Google for directions (You can restrict the API key to only allow your server's IP address) and then pass the response back to your app.
Potentially another gotcha here though, is if your server makes that request, what's stopping someone just hitting your server for map directions and running up your Google Cloud bill that way? You'll probably need to have authentication on your app, that sends a token to your server to make sure it's a legitimate request from your app.
Also worth noting that this library wont work if you do that. As it makes the request to Google and that's not configurable, you'd need to either fork this package and alter it with your API endpoint or you could just grab the component from here and place it in your app with some alterations.
I have api key restricted to android apps, and enabled maps and directions api, and maps are working but directions not with "ReactNativeJS: MapViewDirections Error: Error on GMAPS route request: This IP, site or mobile application is not authorized to use this API key. Request received from IP address xx.xxx.xxx.xxx, with empty referer" error. I tried with key that does not have restrictions and it works. So if someone knows how to get it work but with restrictions it would be great. Thank you.