Android app authentication with existiing website

I have a website which uses nodejs and passportjs for authentication. I now need to use this system to login with my android application. I am unsure as to the correct way to proceed. Do I simply use the website and load it in a web view itself? Is this the correct way to do ? Otherwise I would have to probably send the username and password for the first time and establish a token. Are there any libraries with android support which do this ? Could someone please help me out?

Follow the following steps and hopefully you will get your app to do what you want:

  • Step 1: Create a Login View in your android app that allows users to enter email/username and password.
  • Step 2: Secondly, get their username/email and password (encrypt the passwords) and then:
  • Step 3: Create an AsyncTask - you can learn how to do that using Android Documentation. In that AsyncTask,
  • Step 4: Using HttpRequest, make a POST request to your website by passing a long the user credentials.
  • Step 5: Since you already know how to handle login processes on the site, you can do the same using the http request from Android. Then if the user is successfully logged in,
  • Step 6: Simply return a JSON response to verify that a user was successfully logged in or not.

Once they are logged in, you can redirect them to their profile or protected resources as you wish.

I hope this helps.