Automatically login to Gmail using a WebView?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 22:06:17

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/11352792/automatically-login-to-gmail-using-a-webview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!