Protecting an application only with hard-coded credentials, as already mentioned, is not secure.
I should suggest you use some login structure. Where do you first ask for a username / password.
Then you create a upp API call using a signature that you compile at runtime. By doing this, you never need to send users password over an open network.
You can achieve this by calling as follows:
APIkey = "a specicic APIkey"; //To identify the specifik app "not secret" Username = "usersname"; //To identify witch user trying to make the call Request = "you needed request data"; //Your actual requst parameters. Timestamp = "Current_timestamp"; //Current timestamp user to get unique signatures for every call Signature = sha256_hash(APIkey + Username + Request + Timestamp + Password); //Signature using the users password(Secret).
You can then verify the call by recompiling the name server, as well as using the saved password in your database. If the signatures match, the call must be authentic. You should also set timelimit and reject every call that is old.
Note: you probably need to adapt and change it to working code in your language, but you get this idea.
source share