简体   繁体   English

具有existiing网站的Android应用认证

[英]Android app authentication with existiing website

I have a website which uses nodejs and passportjs for authentication. 我有一个使用nodejs和passportjs进行身份验证的网站。 I now need to use this system to login with my android application. 我现在需要使用这个系统登录我的Android应用程序。 I am unsure as to the correct way to proceed. 我不确定正确的方法。 Do I simply use the website and load it in a web view itself? 我只是简单地使用网站并将其加载到Web视图中吗? 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 ? 有没有任何带有android支持的库可以做到这一点? 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. 第1步:在Android应用程序中创建一个登录视图,允许用户输入电子邮件/用户名和密码。
  • Step 2: Secondly, get their username/email and password (encrypt the passwords) and then: 第2步:其次,获取用户名/电子邮件和密码(加密密码),然后:
  • Step 3: Create an AsyncTask - you can learn how to do that using Android Documentation. 第3步:创建AsyncTask - 您可以使用Android文档了解如何执行此操作。 In that AsyncTask , 在那个AsyncTask中
  • Step 4: Using HttpRequest, make a POST request to your website by passing a long the user credentials. 第4步:使用HttpRequest,通过传递一个很长的用户凭据,向您的网站发出POST请求。
  • 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. 步骤5:由于您已经知道如何处理站点上的登录过程,因此您可以使用Android的http请求执行相同的操作。 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. 步骤6:只需返回JSON响应即可验证用户是否已成功登录。

Once they are logged in, you can redirect them to their profile or protected resources as you wish. 登录后,您可以根据需要将其重定向到其个人资料或受保护资源。

I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM