diff --git a/README.md b/README.md index 813bd98..7045b91 100644 --- a/README.md +++ b/README.md @@ -375,7 +375,9 @@ ImapConnection Functions * **password** - <_string_> - Password for plain-text authentication. - * **xoauth** - <_string_> - OAuth token for [OAuth authentication](https://sites.google.com/site/oauthgoog/Home/oauthimap) for servers that support it. + * **xoauth** - <_string_> - OAuth token for [OAuth authentication](https://sites.google.com/site/oauthgoog/Home/oauthimap) for servers that support it (See Andris Reinman's [xoauth.js](https://github.com/andris9/inbox/blob/master/lib/xoauth.js) module to help generate this string). + + * **xoauth2** - <_string_> - OAuth2 token for [The SASL XOAUTH2 Mechanism](https://developers.google.com/google-apps/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism) for servers that support it (See Andris Reinman's [xoauth2](https://github.com/andris9/xoauth2) module to help generate this string). * **host** - <_string_> - Hostname or IP address of the IMAP server. **Default:** "localhost" @@ -637,4 +639,4 @@ Several things not yet implemented in no particular order: * UNSELECT (via UNSELECT extension -- http://tools.ietf.org/html/rfc3691) * SORT (via SORT extension -- http://tools.ietf.org/html/rfc5256) * THREAD (via THREAD=ORDEREDSUBJECT and/or THREAD=REFERENCES extension(s) -- http://tools.ietf.org/html/rfc5256) - * ID (via ID extension -- http://tools.ietf.org/html/rfc2971) ? \ No newline at end of file + * ID (via ID extension -- http://tools.ietf.org/html/rfc2971) ? diff --git a/lib/imap.js b/lib/imap.js index f4054ad..b5a71ba 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -1198,6 +1198,9 @@ ImapConnection.prototype._login = function(cb) { if (this._serverSupports('AUTH=XOAUTH') && 'xoauth' in this._options) { this._send('AUTHENTICATE XOAUTH ' + utils.escape(this._options.xoauth), fnReturn); + } else if (this._serverSupports('AUTH=XOAUTH2') && 'xoauth2' in this._options) { + this._send('AUTHENTICATE XOAUTH2 ' + utils.escape(this._options.xoauth2), + fnReturn); } else if (this._options.username !== undefined && this._options.password !== undefined) { this._send('LOGIN "' + utils.escape(this._options.username) + '" "'