• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Retrict REST-API so that only my app can use it

Tobbe237

Lurker
Mar 24, 2019
3
0
I am using "PHP-CRUD-API" (https://github.com/mevdschee/php-crud-api) to do operations on a MySQL-database. It works very well, but the problem is that everyone else can also do the operations, because the REST-API only needs an URL to make queries.

For example if anyone uses a software that sets the request type to DELETE and use this URL: "localhost/api.php/mytable/1" they would delete 1 row in "mytable" which is in my MySQL database.

This may be a combination of Android/PHP/MySQL related topic, but I was wondering if anyone could tell me how I can make it so that my Android app is the only app/place that can successfully do queries to my database?

(I have so far only been coding in Android Studio by using Java, and do not have a lot of knowledge about PHP and MySQL, which is why I chose to ask for help in this Android forum).
 
Basically you need authentication credentials for your REST API.
What is normally done here is to provide users with some kind of login service, which of course requires them to supply a login name and password. Once that check passes, then any subsequent REST calls will include an authentication token, which was passed back to your app after a successful login.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones