Google IMAP XOAuth仅适用于身份验证

时间:2012-04-24 19:47:33

标签: java oauth gmail

我正在尝试使用XOAuth使用来自Google Apps收件箱的最新邮件填充portlet。然而,它似乎在战斗我的每一步。我使用的是来自This Page的2-legged代码。

我在验证时遇到了问题,但是在支持我的Javamail版本到1.4 auth后开始工作。但是,每当我尝试列出文件夹内容甚至 EXAMINE 文件夹时,我都会收到无效凭据错误。

DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: mail.imap.fetchsize: 16384
DEBUG: enable SASL
DEBUG: SASL mechanisms allowed: XOAUTH
* OK Gimap ready for requests from 198.133.178.17 o7if44308676igp.16
A0 CAPABILITY
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH
A0 OK Thats all she wrote! o7if44308676igp.16
IMAP DEBUG: AUTH: XOAUTH
DEBUG: protocolConnect login, host=imap.gmail.com, user=user@cnm.edu, password=<non-null>
IMAP SASL DEBUG: Mechanisms: XOAUTH
IMAP SASL DEBUG: SASL client XOAUTH
A1 AUTHENTICATE XOAUTH
+ 
IMAP SASL DEBUG: challenge:  :
IMAP SASL DEBUG: response: GET https://mail.google.com/mail/b/user@cnm.edu/imap/?xoauth_requestor_id=user%40cnm.edu oauth_consumer_key="cnm.edu",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1335245518",oauth_nonce="4720724339258128",oauth_version="1.0",oauth_signature="7HAU4923Gy7%2Ffqb3avk7Tg%2FXtVM%3D" :
R0VUIGh0dHBzOi8vbWFpbC5nb29nbGUuY29tL21haWwvYi9saG9sY29tYjJAY25tLmVkdS9pbWFwLz94b2F1dGhfcmVxdWVzdG9yX2lkPWxob2xjb21iMiU0MGNubS5lZHUgb2F1dGhfY29uc3VtZXJfa2V5PSJjbm0uZWR1IixvYXV0aF9zaWduYXR1cmVfbWV0aG9kPSJITUFDLVNIQTEiLG9hdXRoX3RpbWVzdGFtcD0iMTMzNTI0NTUxOCIsb2F1dGhfbm9uY2U9IjQ3MjA3MjQzMzkyNTgxMjgiLG9hdXRoX3ZlcnNpb249IjEuMCIsb2F1dGhfc2lnbmF0dXJlPSI3SEFVNDkyM0d5NyUyRmZxYjNhdms3VGclMkZYdFZNJTNEIg==
got folder: INBOX
DEBUG: connection available -- size: 1
A2 EXAMINE INBOX
A1 NO [ALERT] Invalid credentials (Failure)
A2 BAD Unknown command o7if44308676igp.16
A3 LOGOUT
* BYE Logout Requested o7if44308676igp.16
A3 OK Quoth the raven, nevermore... o7if44308676igp.16
Exception in thread "main" javax.mail.MessagingException: A2 BAD Unknown command o7if44308676igp.16;
  nested exception is:
    com.sun.mail.iap.BadCommandException: A2 BAD Unknown command o7if44308676igp.16
    at com.sun.mail.imap.IMAPFolder.open(IMAPFolder.java:829)
    at TwoLegged.main(TwoLegged.java:37)
Caused by: com.sun.mail.iap.BadCommandException: A2 BAD Unknown command o7if44308676igp.16
    at com.sun.mail.iap.Protocol.handleResult(Protocol.java:296)
    at com.sun.mail.imap.protocol.IMAPProtocol.examine(IMAPProtocol.java:636)
    at com.sun.mail.imap.IMAPFolder.open(IMAPFolder.java:811)
    ... 1 more

我现在处于亏损状态。 Gmail OAuth Docs并不表示除了身份验证之外的任何请求都需要签名,但无效凭据错误似乎意味着其他情况?

1 个答案:

答案 0 :(得分:0)

事实证明我有一个Java版本,它不适合1.4版本的javamail版本,这正是我所需要的。

我将Java从1.6.0_21升级到1.6.0_24。