FaridSafi / react-native-google-places-autocomplete

Customizable Google Places autocomplete component for iOS and Android React-Native apps
MIT License
2.01k stars 852 forks source link

Support adding headers to the request for auth #865

Open derekmurawsky opened 1 year ago

derekmurawsky commented 1 year ago

Is your feature request related to a problem? Please describe.

In order to provide some level of security for the semi-sensitive api keys used by this library, request restrictions are encouraged by google. As documented here (thanks @matijagrcic), the native ways of doing so are via headers.

Header x-android-package
Label servicecontrol.googleapis.com/android_cert_fingerprint

Header x-android-cert 
Label servicecontrol.googleapis.com/android_package_name

Header x-ios-bundle-identifier
Label servicecontrol.googleapis.com/ios_bundle_id

Describe the solution you'd like

Enable either adding additional request headers to the outbound request generically so that this functionality can be emulated. This seems to be a flexible way to support various request restrictions including by referrer when doing local app development.

OR

Support automatically sending these headers with each request via a toggle of some kind. something like send-native-app-id=true. Much simpler to enable from a user perspective, but also less flexible.

Describe alternatives you've considered

Additional context

I would suggest that, as a react-native library, this should support android and IOS native methods of security for APIs like this.

KrisLau commented 1 year ago

@bell-steven