I'm a total novice in web development.
I'm making an android app for someone's wordpress site. They have a mysql database containing private user data which which I need to retrieve in the app when a user is signed in.
I wrote a tiny, insufficient api in php that fetches private data for a user and returns it given a user ID, obviously this isn't good enough, but this is pretty much where I'm stuck.
I need to ensure that only the currently logged in user can access their own data. I've tried to go down the oauth2 route using the WP OAuth Server plugin. I get how oAuth2 works at a high level, but actually integrating it is giving me a lot of questions like:
- How would the user be authenticated before they're given an authorisation code?
- If the authorisation step is just checking that the user is logged in, then anyone could access this user's data as long as they're logged in on some device, which doesn't sound good.
- Once I have the access token how is that validated when I call the API that retrieves the user's data
So basically, my questions: Is oAuth2 the best option for achieving this? If yes, then I want to ask the 3 questions above. If no, what is?