If I'm creating an IOS React Native app, where is the best place to store client secrets for external APIs? I see a lot of tutorials and such that just hard code them, but proceed to say something along the lines of "DON'T DO THIS" without actually providing a valid example of how to actually do it for something production level.
top of page
bottom of page
It is generally not recommended to store client secrets for external APIs in your React Native app, as this can potentially expose your secrets to anyone who has access to the app's code. Instead, you should store your secrets on a server that your app can communicate with, and use the server to make requests to the external APIs on behalf of your app. This way, the secrets are not included in the app itself and are less likely to be compromised.
There are several ways you can implement this approach in a React Native app. One common method is to use a server-side proxy to make requests to the external APIs. Your app would send a request to the proxy, which would then add the necessary client secrets and make the request to the external API on behalf of your app. The proxy could then pass the response back to your app. This way, the client secrets are never included in the app itself and are only accessible to the proxy.
Another option is to use a server-side authentication flow to obtain access tokens for the external APIs. Your app would initiate the authentication flow by redirecting the user to a login page on the server. Once the user has successfully logged in, the server would then provide the app with an access token that can be used to make requests to the external API on behalf of the user. This approach can be more secure, as it allows you to use short-lived access tokens that can be easily revoked if necessary.
In general, it is important to carefully consider how you handle sensitive information like client secrets in your app, and to take steps to protect that information from unauthorized access. Using a server-side proxy or an authentication flow can help ensure that your client secrets are not included in the app itself and are less likely to be compromised.