I have developed a website in PHP ( zend framework 2 ). It has user authentication to access user specific content and views which is only accessed by the user. Now I want to create a mobile app which has same functionailty as this. So I created a web service to access all require methods to access data. Now I have to authenticate user from mobile app . So user should be able to login once using his credentials in mobile and he should be able to access his content.
My Idea is , after user is authenticated ,subsequent API calls should communicate with web service using a token provided by web service. I have basic understanding of oAuth. So my plan is to create an oAuth server in my application which provides secret key for my app. App connects using secret and gets a token when authenticated. App uses this token for further API calls.
Now my questions are
- Am I using oAuth correctly or isnt this oAuth for.
- Is there any better implementation than this.
- I have searched to see similar implimentations but all I found when I tried oAuth keyword is google oauth Authentication.
- What are alternatives to authenticate user from mobile app with login credentials we have in database.
Yes, you are on the right track to some extent but let me suggest a way which is used in the industry for a while now.
1st read question and answer to get the basic idea of how it should be done.
How to implement 'Token Based Authentication' securely for accessing the website's resources(i.e. functions and data) that is developed in PHPFox?
Then read this post to grasp idea about JWT.
Okay now let's see how you can implement it JWT in your application. For that read this post. Ignore the NodeJS/Angular stuff. Think of them as your application server instead. Try to understand the rationale behind it.
I have provided you URLs since I don't wanna repeat here what's already out there in the internet but I have given you the path to solve your problem in a better way. Please let me know if you need future clarifications on this.