Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8880869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:14:20+00:00 2026-06-14T20:14:20+00:00

So, I realize that SASL is not implemented in android, and that consequently the

  • 0

So, I realize that SASL is not implemented in android, and that consequently the javamail oauth2 methods won’t out of the box.

However, according to the google api docs for gmail imap (https://developers.google.com/google-apps/gmail/xoauth2_protocol) it would seem fairly trivial to get an auth token, encode it, and send the ‘AUTHENTICATE XOAUTH2 ‘ to the server manually.

My problem: I want to use the javamail IMAP functions (don’t want to handle IMAP protocol commands and response munging myself), but I need a way to simply insert the proper authentication command – not the traditional login username password.

Can this be done and what would be the easiest way to go about it? Could I create my own authentication method and implement this easily?

Alternatively, can I create the connection and then hand this off to an IMAPStore (doubt this would work as it creates and manages a connection pool).

—Edit—

Just to be more specific, the javax.security.sasl method is not implemented in Android which Imap.protocol.IMAPSaslAuthenticator relies on.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:14:21+00:00Added an answer on June 14, 2026 at 8:14 pm

    I have a working jar with sasl support for imap (for smtp you have to issue the command as you said because java mail for android doesn’t have the sasl infrastructure for smtp).
    All I did was to add the packages javax.security.sasl and javax.security.auth.callback to the java mail for android source and repackage it. I had to put the in a different namaspace, myjavax.security.sasl etc. because otherwise android build system complains that the package contains core libraries, not sure why it doesn’t complain for javax.mail which is in a core namespace anyway (javax). I also had to change some import for the new namespace in some classes, but basically are the packeges classes themselves and com.sun.mail.imap.protocol.IMAPSaslAuthenticator.
    With this I could successfully authenticate to gmail imap server using the oauth 2 token I got from the Android AccountManager, I didn’t try anything else. For smtp, you can look at my answer here Javamail api in android using XOauth
    I think it’s possible to make smtp work with Sasl getting the new classes from here http://kenai.com/projects/javamail/sources/mercurial/show/mail/src/main/java/com/sun/mail/smtp which have Sasl support for smtp.
    I think this is perfectly fine because all I do is adding some GPL classes, the one that I added are from the JDK.
    Hope this helps, if you need the jars or some more explanation on how to do it, just ask.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realize that temporary tables are session/connection bound and not visible or accessible out
I realize that virtual template functions are not allowed in c++. Because of my
I realize that you can use SoundPlayer to play a sound in C#; however,
I realize that adding methods to native JavaScript objects (Object, Function, Array, String, etc)
I realize that Go does not have classes but pushes the idea of structs
I realize that the value 0.00 is not a valid nonNegativeInteger, nor is it
I realize that this is a question that will probably not have a single
I realize that there are a couple other posts on this topic, however the
I realize that it's been asked and answered that Visual Studio does not support
I realize that this question might not make sense to some, but I was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.