Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

API Key storage in Ionic Securely

I am developing an Ionic 4 Application and it requires making http call to consume data from an API.For the same , there is a need to add key with http request. I want to know , how can I store api key securely , instead of putting it directly into service while building .apk for my application. I presume , there is no concept of environment file which was there in Angular. I have tried putting in API key in config.xml but not sure wether it is a good practice to put in api key in config file and also not aware of how to read the same from config file to service file.

Since , there are not much pointers available online, requesting to help. Thanks in advance.

like image 772
Avinash Avatar asked Feb 26 '26 02:02

Avinash


1 Answers

You can store your api_key on the server and by using angular APP_INITIALIZER token you can call API to get api_key dynamically before app initializes and store them.

In this way, you can always handle your api_key via server. So if someone gets your code, he/she will not get your api_key.

like image 61
gaurav soni Avatar answered Feb 28 '26 16:02

gaurav soni



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!