简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM