Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native google api restrictions

When using firebase or react-native-google-places-autocomplete, I need to supply an api key. Obviously, I can't use a native api key, as the calls are made using web clients. So I have to use a web api key. The problem is, I can't get it to be restricted in google console, because I have no referrer or IP address. Is there any way to solve this?

like image 437
atlanteh Avatar asked Apr 24 '17 08:04

atlanteh


People also ask

What is the limit to access to the API using a key?

Access to the API using a key is limited to 300 requests per minute. Every API response includes the following set of headers to identify the status of your consumption.

Are Google API key sensitive?

The maps API key is not sensitive, in the sense that Google does not treat it as sensitive information.

How do I secure API keys in react-native?

If you must have an API key or a secret to access some resource from your app, the most secure way to handle this would be to build an orchestration layer between your app and the resource.


1 Answers

You cannot create a "restricted" key for react-native-google-places-autocomplete, because it does not use the native SDKs. The only API key protection the is available, is to restrict the Google APIs that the key can use (e.g. Google Places, Geocode).

Even though it is not difficult to reverse engineer or check the network calls in a React Native App (or any app for that matter), the key is not out in the open like it would be on a website, where you can just open the dev tools and see the key). If you are concerned about someone using the key, I would recommend sending the api key on app startup, so that if the key were compromised you can swap out the key.

As mentioned in one of the other answers, react-native-google-places uses the native Google Maps SDKs, and therefore it should be possible to use a restricted key with it.

Full disclosure: I am the current maintainer of react-native-google-places-autocomplete.

like image 161
Steven Bell Avatar answered Sep 17 '22 17:09

Steven Bell