使用XOAUTH Android上无法连接到Gmail的IMAP [英] Cannot connect to Gmail IMAP using XOAUTH on Android

查看:352
本文介绍了使用XOAUTH Android上无法连接到Gmail的IMAP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建一个使用Gmail的备份一些数据的应用程序。我用XOAUTH连接到Gmail,并获得令牌和秘密。但我无法连接到Gmail的IMAP服务。我跟着例子在 HTTP:/ /$c$c.google.com/p/google-mail-xoauth-tools/wiki/JavaSample$c$c

I'm building an app that uses Gmail to backup some data. I use XOAUTH to connect to Gmail and got the token and secret. But i could not connect to Gmail's IMAP service. I followed the example at http://code.google.com/p/google-mail-xoauth-tools/wiki/JavaSampleCode:

Properties props = new Properties();
props.put("mail.imaps.sasl.enable", "true");
props.put("mail.imaps.sasl.mechanisms", "XOAUTH");
props.put(OAUTH_TOKEN_PROP, oauthToken);
props.put(OAUTH_TOKEN_SECRET_PROP, oauthTokenSecret);
props.put(CONSUMER_KEY_PROP, Const.CONSUMER_KEY);
props.put(CONSUMER_SECRET_PROP, Const.CONSUMER_SECRET);
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;

在运行时,它会报告以下异常。

When runs, it reports the following exception.

javax.mail.MessagingException: * BYE [UNAVAILABLE] Temporary System Error;
   nested exception is:
    com.sun.mail.iap.ConnectionException: * BYE [UNAVAILABLE] Temporary System Error
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:569)
    at javax.mail.Service.connect(Service.java:288)
    at com.doodlemobile.zy.finenote.OAuthHelperActivity$XoauthAuthenticator.connectToImap(OAuthHelperActivity.java:565)
    at com.doodlemobile.zy.finenote.OAuthHelperActivity$ConnectGmailTask.doInBackground(OAuthHelperActivity.java:484)
    at com.doodlemobile.zy.finenote.OAuthHelperActivity$ConnectGmailTask.doInBackground(OAuthHelperActivity.java:1)
    at android.os.AsyncTask$2.call(AsyncTask.java:287)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
    at java.lang.Thread.run(Thread.java:856)
 Caused by: com.sun.mail.iap.ConnectionException: * BYE [UNAVAILABLE] Temporary System Error
    at com.sun.mail.iap.Protocol.handleResult(Protocol.java:346)
    at com.sun.mail.imap.protocol.IMAPProtocol.login(IMAPProtocol.java:336)
    at com.sun.mail.imap.IMAPStore.login(IMAPStore.java:615)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:549)
    ... 11 more

我用SUN的JavaMail的。任何人能帮助我吗?

I used javamail of SUN. Anyone would help me ?

推荐答案

我面临着同样的问题。

启用调试完毕后( session.setDebug(真))我注意到,我收到的 ClassNotFoundException的 的Tempory系统错误正在上映之前。

After enabling debugging (session.setDebug(true)) I noticed that I was receiving a ClassNotFoundException before the Tempory System Error was being shown.

08-06 14:38:59.148: I/System.out(3139): DEBUG IMAP: Can't load SASL authenticator: java.lang.ClassNotFoundException: com.sun.mail.imap.protocol.IMAPSaslAuthenticator
08-06 14:38:59.148: I/System.out(3139): DEBUG IMAP: LOGIN command trace suppressed
08-06 14:39:00.265: I/System.out(3139): DEBUG IMAP: LOGIN command result: * BYE [UNAVAILABLE] Temporary System Error
08-06 14:39:00.289: E/com.example.gmailandroid.MainActivity(3139): * BYE [UNAVAILABLE] Temporary System Error
08-06 14:39:00.289: E/com.example.gmailandroid.MainActivity(3139): javax.mail.MessagingException: * BYE [UNAVAILABLE] Temporary System Error;
08-06 14:39:00.289: E/com.example.gmailandroid.MainActivity(3139):   nested exception is:
08-06 14:39:00.289: E/com.example.gmailandroid.MainActivity(3139):  com.sun.mail.iap.ConnectionException: * BYE [UNAVAILABLE] Temporary System Error
08-06 14:39:00.289: E/com.example.gmailandroid.MainActivity(3139):  at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:668)

翻翻JavaMail的源$ C ​​$ C这样看来,这是因为它试图加载com.sun.mail.imap.protocol.IMAPSaslAuthenticator这对非Android的Java资源的依赖关系。

Looking through the JavaMail source code it would appear that this is because it is trying to load com.sun.mail.imap.protocol.IMAPSaslAuthenticator which has dependencies on non-android java resources.

javax.security.sasl.*

这篇关于使用XOAUTH Android上无法连接到Gmail的IMAP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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