In the code above you can see the select query is validating and fetching the user details for i.e- FirstName, LastName, Email, Mobile etc. Once this token is found match with any user's detail, then these details will be set on the public var current_user.
In the case if token does'nt found matched with any user, web server will return a false message in JSON form.
Now you have to call this function from every API and by doing using the below method:
The above method will authenticate and fetch the users detail into a variable. that variable can be used as a public which you can be accessed in another API.
So, this how we makes a token based approach which do same function as sessions do in website. If you have any questions or inputs plese feel free to write in comment section below.