Move google maps api key out of expo.json?

#1

Whats the recommended way to set android.config.googleMaps.apiKey without saving the key in expo.json? Reason being, expo.json is checked into our public repository and I’d rather not have my dev key out there in the wild.

When developing in native Android, I simply reference environment variables that store my secret keys from my gradle files. Is there anything similar for expo?

0 Likes

#2

Hi! I assume you mean exp.json or app.json rather than expo.json :smiley:

If you check this into a public repository then I would recommend checking in exp.json.example or app.json.example with a blank android.config.googleMaps.apiKey and then removing exp.json or app.json from source control and adding it to your gitignore.

0 Likes

#3

You’re right, I meant exp.json. Thanks for the suggestion, this seems like quite the hack though as it forces you to manually maintain consistency between the two files. I take it there’s no current work being done in handling this in a more programmatic way?

1 Like

#4

This is actually pretty common practice for a lot of similar tools, eg: dotenv users will have a .env.example file (read this thread for what some people do to get around the sync’ing issue you mentioned). Some other discussion on the Ruby version of this is pretty interesting too.

Ideally the configuration would be a JS file rather than json so you can import whatever you like and use env vars and such, but we don’t have any plans to work on this right now because compared to the other things that we could work on it is very low impact. Another alternative would be app.json.local which you don’t commit to source control, and the keys are merged into app.json – this would be much easier to add.

If you’re interested in working on either of these approaches it would be very welcome – check out XDL, in particular this chunk.

1 Like