Hello all,

I recently started experimenting with OAuth access to apps domain
email accounts. Using the sample for OAuth access provided by google,
here is the code I was using.


String userEmail = user.getEmail();
LOGGER.info("Using email:" + userEmail);
String smtpHost = "smtp.googlemail.com";
int smtpPort = 587;
Properties props = new Properties();
props.put("mail.smtp.ehlo", "true");
props.put("mail.smtp.auth", "false");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.starttls.required", "true");
props.put("mail.smtp.sasl.enable", "false");
Session session = Session.getInstance(props);
session.setDebug(true);
LOGGER.info("Created SMTP Session:" + userEmail);
final URLName unusedUrlName = null;
SMTPTransport smtpTransport = new SMTPTransport(session,
unusedUrlName);
// If the password is non-null, SMTP tries to do AUTH LOGIN.
final String emptyPassword = null;
// IT FAILS HERE
smtpTransport.connect(smtpHost, smtpPort, userEmail, emptyPassword);

LOGGER.info("Transport Connected");
XoauthSaslResponseBuilder builder = new XoauthSaslResponseBuilder();
byte[] saslResponse = builder.buildResponse(userEmail,
            XoauthProtocol.SMTP,
            //oauthToken,
            //oauthTokenSecret,
            getOAuthConsumer());
 LOGGER.info("Unencoded response:" + saslResponse);
saslResponse = BASE64EncoderStream.encode(saslResponse);
LOGGER.info("Encoded response:" + saslResponse);
smtpTransport.issueCommand("AUTH XOAUTH " + new String(saslResponse),
235);
.......
// Now use regular java to send an email on behalf of the user.
......


The problem is when SMTP transport tries to connect, it raises an
exception

java.lang.NoClassDefFoundError: java.net.Socket is a restricted class.
Please see the Google App Engine developer's guide for more details.

Now, I know that you can't use sockets on app engine....so I am not
surprised by the exception. But on the other hand, you have to open a
socket for XOAUTH to work and send the oauth signature. Does this
mean, you can't use this feature to send mails (on behalf of other
users) using oauth from appengine or am I not complete off base? By
the way access to other google data apis' like calendar and
spreadsheets works great for market place apps.

This is my first mail so please apologize me if this isnt' the right
forum to ask these sorts of questions.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to