获取gmail Xoauthtoken,访问gmail邮件?

时间:2012-03-23 13:31:12

标签: android gmail imap token pop3

大家好,             最后,在没有获得任何使用contentprovider删除邮件的解决方案后,我转移到IMAP / POP3库。我使用xoauth库连接到IMAP,但其connectToImap方法使用六个参数,我无法得到两个参数oauthToken, oauthTokenSecret。请告诉我如何获取这些参数?

~~~

      public static IMAPSSLStore connectToImap(String host, int port,
            String userEmail, String oauthToken, String oauthTokenSecret,
            OAuthConsumer consumer, boolean debug) throws Exception {
        Properties props = new Properties();
        props.put("mail.imaps.sasl.enable", "true");
        props.put("mail.imaps.sasl.mechanisms", "XOAUTH");
        props.put(XoauthSaslClientFactory.OAUTH_TOKEN_PROP, oauthToken);
        props.put(XoauthSaslClientFactory.OAUTH_TOKEN_SECRET_PROP,
                oauthTokenSecret);
        props.put(XoauthSaslClientFactory.CONSUMER_KEY_PROP,
                consumer.consumerKey);
        props.put(XoauthSaslClientFactory.CONSUMER_SECRET_PROP,
                consumer.consumerSecret);
        Session session = Session.getInstance(props);
        session.setDebug(debug);

        final URLName unusedUrlName = null;
        IMAPSSLStore store = new IMAPSSLStore(session, unusedUrlName);
        final String emptyPassword = "";
        store.connect(host, port, userEmail, emptyPassword);
        return store;
    }
~~~

0 个答案:

没有答案