使用Node.js和Passport通过Androidlogin系统的方法
我目前正在开发一个使用Node.js / ExpressJS和Passport作为login系统的Web服务。 在networking上一切正常。
我想创build一个Android应用程序,可以通过httppost / JSONlogin到服务器,并获得访问用户configuration文件及其所有variables。
目前我正在使用一个非常愚蠢和不安全的方法。
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.login); Duan duan = ((Duan)getApplicationContext()); String output = ""; try { output = new LoginTask().execute(jsonURL).get(); Log.v("JSON: ", output); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } JSONObject jsonObject; try { jsonObject = new JSONObject(output); String username = jsonObject.getString("username"); String user_id = jsonObject.getString("_id"); duan.setUserId(user_id); duan.setUsername(username); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
正如你所看到的,我将_id和username字段存储在一个可以跨应用程序访问的单例中。
有没有一种更好,更安全的方式来编程Android的系统上的日志与Node.js和Passport一起工作?
谢谢,丹尼斯
- 移动应用程序:restful api或sdk dynamodb
- Android的APK构build失败“多个文件被发现与操作系统无关的path'lib / arm64-v8a / libc ++ _ shared.so'”
- 套接字连接 – Java添加字节
- Apache Cordova和PhoneGap有什么区别?
- 是否有可能调用方法JavaScript从android没有webview?
- ios-deploy安装失败
- 后端的select?
- 使用Node.jsencryption模块进行encryption并使用Java解密(在Android应用程序中)
- 天气 – >简单的API在Node.js->如何发送android推送通知?