如何在SWT浏览器中登录Gmail帐户? [英] How to login to Gmail account in SWT browser?

查看:82
本文介绍了如何在SWT浏览器中登录Gmail帐户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Java应用程序中有一个嵌入式SWT浏览器.我想使用用户名和密码直接在此浏览器中登录我的gmail帐户.我不想在浏览器中看到登录页面,我想直接转到邮件.这可能吗?我该将URL设置为什么?是否可以借助javascript来实现?

I have an embedded SWT browser in my Java application.I want to directly login to my gmail account in this browser given username and password .I dont want to see the login page in the browser and i want to go directly to the mail.Is this possible?What do i set the URL to?Is it possible by taking help of javascript?

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;


public class Dummy2 {

    public static void main(String args[])
    {
        Display display = new Display();
        Shell shell = new Shell(display);

        shell.setLayout(new FillLayout());

        Browser b= new Browser(shell,SWT.NONE);

        b.setUrl("www.Gmail.com");
        //b.setText("<html><body> Helllooooooooooooo </body></html>");

        shell.open();
        while (!shell.isDisposed()) {
            //while (BGTrayApp.isOpen) {
                if (!display.readAndDispatch())
                    display.sleep();
            }


    }



}

推荐答案

我怀疑这是可能的,并且当然不建议这样做.Google可能内置了防止这种情况发生的保护措施,因为它可以更轻松地进行中间人攻击.另外,如何处理启用了双重身份验证(Google Authenticator)的帐户?在这种情况下,提交登录表单后会要求您提供令牌.

I doubt that this is possible, and it's certainly not advisable. Google likely has protections built-in to prevent this, as it can make it easier to conduct man-in-the-middle attacks. Also, how do you handle accounts that have two-factor auth (Google Authenticator) enabled? In these cases, you're asked for a token after the login form has been submitted.

您为什么需要这样做?您是否考虑过其他选择?

Why do you need to do this? Have you considered any alternatives?

这篇关于如何在SWT浏览器中登录Gmail帐户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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