I have created this web app and I created have this API. For the sake of this example, let's keep it simple:
My app needs to know how many "credits" the user has. The api has a call get_credits that returns { credits: 1000 }
Now, how do I prevent somebody to use a hostfile (or some other method) to create his own api that returns { credits: 2000 }.
I was thinking of inserting a hash of some sort, but because it is javascript, the hash is easily extracted from the source. Same goes for a handshake I guess.
So, how do I make the api secure enough?