使用WebView自动登录到Gmail? [英] Automatically login to Gmail using a WebView?

查看:212
本文介绍了使用WebView自动登录到Gmail?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用用户的Gmail用户名和密码在 WebView 内自动登录Gmail。是否有任何现有的代码如何做到这一点,因为我有麻烦(哪些隐藏的字段需要发布,获取/重新注入cookie)。



我试图简单地使用JavaScript来填写用户名/密码字段,但是在提交登录表单时(再次使用JavaScript), WebView 询问用户是否希望保存密码,这是我需要避免的(使其真正自动)。



谢谢,

尼克

解决方案

  WebSettings mWebSettings = mWebView.getSettings(); 
mWebSettings.setSavePassword(false);
mWebSettings.setSaveFormData(false)

试试这个,不确定是否setSave [..但是等待:假设你真的只是简单地用JavaScript填充登录表单,你会以纯文本形式存储密码吗?

如果是这样,你不应该这样做,不仅是由于安全问题。我假设你通过一个对话框询问用户的密码。
询问密码似乎对很多用户可疑。



我建议学习如何保存和恢复cookie。


I'd like to use the user's Gmail username and password to automatically login to Gmail inside a WebView. Is there any existing code how to do this, as I'm having trouble with it (which hidden fields need to be posted, getting/re-injecting the cookie).

I have tried to simply fill in the username/password-fields using JavaScript, which works, but on submitting the login-form (using JavaScript again), the WebView asks the users whether he/she wants the password to be saved, which I need to avoid (to make it truly automatic).

Thanks,
Nick

解决方案

WebSettings mWebSettings = mWebView.getSettings();
mWebSettings.setSavePassword(false);
mWebSettings.setSaveFormData(false)

Try this, not sure if both setSave[...] methods are required though.

But wait: Assuming you really just simply fill the login-form with JavaScript, do you store the password in plain text? If so, you shouldn't do that, not only due to security issues. I assume you're asking the user for his/her password via a Dialog. Asking for the password seems suspicious to a lot of users.

I suggest learning how to save and restore cookies instead.

这篇关于使用WebView自动登录到Gmail?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆