Closed cmatthews555 closed 4 years ago
You should be able to do this using the requestUrl
prop. See the signature here.
I understand what you're saying and I tried it out. That worked for me, thanks!
If we use this solution, we need a way to whitelist the request made by the RN app. One way to do this is to use bearer token in the header, however the library does not support passing the token. Is there any other option that you recommend?
If you think passing token in header is viable solution, should I submit a PR?
Might be helpful to anyone else who is trying to implement this: https://www.farhansayshi.com/post/hiding-api-keys-on-react-native-in-10-minutes-with-api-gateway/#adding-proxy-url-to-frontend
Might be helpful to anyone else who is trying to implement this: https://www.farhansayshi.com/post/hiding-api-keys-on-react-native-in-10-minutes-with-api-gateway/#adding-proxy-url-to-frontend
Though this technically solves the problem of hard coding the api key in the app, you still need to authorize api requests to this proxy somehow. The correct (IMO) way to handle this kind of semi-sensitive key is by supporting the native ways of locking it down in both IOS and Android. See this link for guidance https://github.com/FaridSafi/react-native-google-places-autocomplete/issues/787#issuecomment-1013358580
You should be able to do this using the
requestUrl
prop. See the signature here.
@bell-steven Would like to implement this as well. But I cant seem to understand how to use that signature.
Describe the problem
I want to remove the google API key from the source code of my app. Is there another way to get this key to your library? For my other APIs I am using AWS API Gateway to proxy the requests and on the way through it appends the appropriate API key. Can I follow that pattern with this library?
Reproduction - (required - issue will be closed without this)
The library works fine with the hardcoded API key, I'd like to avoid that.
Additional context
Library Version: [e.g. 1.4.2] - 1.6.1
React Native Version: [e.g. 0.62.2] - react-native/archive/sdk-37.0.1
[X] iOS
[X] Android
[X] Web
If you are using expo please indicate here:
Add any other context about the problem here, screenshots etc
I love this library, thanks for taking the time!