We have an Android app that sends some data to a web service, and then the web service saves it on a MySQL database. We want to avoid people using the web service if it is not from within the app itself. I mean, we want to make sure that no one can perform a MITM attack on our app and then send requests from somewhere else to our web service.
We came up with the next idea:
We include a passphrase both on the Android app and on the web service, then with each request to the web service a token using such passphrase and current timestamp is generated in this way:
// Pseudo
String token = md5(private_passphrase + (timestamp / 60));
The generated token is then sent to the web service, which generates another token the same way and compares them. If both are the same, it allows the request.
The idea is that, even if someone sniffs packets sent from our app, they will not be able to use the same request later from some other source.
How good and secure is this solution? Our concern is more about not letting others use our service from outside the app, not about securing the data we send.