XOAUTH2 is a google-specific API, and not supported by Apple's sasl2
libraries, but RFC 7628 (OAUTHBEARER) is.  However, Apple uses a 
different sasl2 callback entry.

The following patch adds support OAUTHBEARER on OSX, so now connections
to gmail will work correctly with a configuration like:

    #
    # Google Mail
    #
    IMAPAccount gmail
    Host imap.gmail.com
    User your_lo...@gmail.com
    SSLType IMAPS
    AuthMechs OAUTHBEARER
    PassCmd "~/scripts/google_oauth/refresh_token"

-- 
Jonathan

diff --git a/src/drv_imap.c b/src/drv_imap.c
index f18500d..95aa344 100644
--- a/src/drv_imap.c
+++ b/src/drv_imap.c
@@ -2146,6 +2146,9 @@ static sasl_callback_t sasl_callbacks[] = {
        { SASL_CB_USER,     NULL, NULL },
        { SASL_CB_AUTHNAME, NULL, NULL },
        { SASL_CB_PASS,     NULL, NULL },
+#ifdef __APPLE__
+       { SASL_CB_OAUTH2_BEARER_TOKEN, NULL, NULL },
+#endif
        { SASL_CB_LIST_END, NULL, NULL }
 };
 
@@ -2163,6 +2166,9 @@ process_sasl_interact( sasl_interact_t *interact, 
imap_server_conf_t *srvc )
                        val = ensure_user( srvc );
                        break;
                case SASL_CB_PASS:
+#ifdef __APPLE__
+               case SASL_CB_OAUTH2_BEARER_TOKEN:
+#endif
                        val = ensure_password( srvc );
                        break;
                default:
@@ -2297,8 +2303,10 @@ done_sasl_auth( imap_store_t *ctx, imap_cmd_t *cmd 
ATTR_UNUSED, int response )
                int rc = sasl_client_step( ctx->sasl, NULL, 0, &interact, &out, 
&out_len );
                if (process_sasl_step( ctx, rc, NULL, 0, interact, &out, 
&out_len ) < 0)
                        warn( "Warning: SASL reported failure despite 
successful IMAP authentication. Ignoring...\n" );
+#ifndef __APPLE__
                else if (out_len > 0)
                        warn( "Warning: SASL wants more steps despite 
successful IMAP authentication. Ignoring...\n" );
+#endif
        }
 
        imap_open_store_authenticate2_p2( ctx, NULL, response );


_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to