Question
I'm designed REST API that is going to be used for iOS and Android apps, and possibly web and other mobile clients in the future.
How do I restrict my entire API to only the clients (apps) that I want to have access? I want to prevent 3rd parties from accessing my API to register users or even login without going through an authorized application (mobile or web client).
Current Ideas
I could give each client that I want to have authorization a secret key, but how do I prevent this key from being extracted from my application's source code (especially easy if my app was a web app)? Also, if the key needs to be changed in the future (due to a compromise) this would be difficult as all my clients would need to be updated, and old clients would fail to function. There has to be a better solution.
I'm using JWT for user authentication, but I fail to see how I can apply this to my problem. I really like how JWT are easily implemented, so it would be great if I could apply a JWT implementation to solve this problem.