XOAuth2 support
joost opened this issue · 2 comments
joost commented
To support XOAuth2 please add to /lib/gmail/client/xoauth2.rb:
require 'gmail_xoauth'
# Usage:
# gmail = Gmail.connect(:xoauth2, email, :token => token)
module Gmail
module Client
class XOAuth2 < Base
attr_reader :token
def initialize(username, options={})
@token = options.delete(:token)
super(username, options)
end
def login(raise_errors=false)
@imap and @logged_in = (login = @imap.authenticate('XOAUTH2', username, token)) && login.name == 'OK'
rescue
raise_errors and raise AuthorizationError, "Couldn't login to given GMail account: #{username}"
end
def smtp_settings
[:smtp, {
:address => GMAIL_SMTP_HOST,
:port => GMAIL_SMTP_PORT,
:domain => mail_domain,
:user_name => username,
:password => {
:token => token
},
:authentication => :xoauth2,
:enable_starttls_auto => true
}]
end
end # XOAuth
register :xoauth2, XOAuth2
end # Client
end # Gmail
johnnyshields commented
Please try latest master. I've merged in @KieranP's fork
johnnyshields commented
This issue was moved to gmailgem/gmail#77