我正在尝试使用 XOAuth 使用来自 Google Apps 收件箱的最新消息填充 portlet。然而,它似乎每一步都在与我作斗争。我正在使用来自: This Page的 2-Legged 代码。
我在进行身份验证时遇到了问题,但是在将我的 Javamail 版本降到 1.4 auth 后开始工作。但是,现在每当我尝试列出文件夹内容甚至EXAMINE文件夹时,都会收到Invalid Credentials错误。
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没有表明除了身份验证之外的任何请求都需要签名,但Invalid Credentials错误似乎暗示其他情况?