How to prevent arbitrary client apps from using anonymous web API?

You can’t prevent people from copying your client code or replaying network traffic.

Thanks to the same origin policy, other web apps can’t access your API from the client. They will have to proxy their requests via the server, meaning these requests will come from a handful of easily identified IP addresses, which you can temporarily blacklist.

As for desktop and mobile apps, there’s not much you can do. My advice is to not worry about them until they’re a problem.

That said, it doesn’t hurt to be prepared. If you want to avoid expensive legal battles, one thing you can do is change your API method signatures from time to time. Leaching apps can be fixed, but their reputation will steadily decline.

Leave a Comment