module MailXoauth2::SmtpXoauth2Authenticator

Public Instance Methods

auth_xoauth2(user, oauth2_token) click to toggle source
# File lib/mail_xoauth2/smtp_xoauth2_authenticator.rb, line 22
def auth_xoauth2(user, oauth2_token)
  check_auth_args user, oauth2_token

  auth_string = build_oauth2_string(user, oauth2_token)
  res = send_xoauth2(base64_encode(auth_string))

  # See note about SMTP protocol exchange in https://developers.google.com/gmail/xoauth2_protocol
  res = get_final_status if res.continue?

  check_auth_response res
  res
end

Private Instance Methods

get_final_status() click to toggle source
# File lib/mail_xoauth2/smtp_xoauth2_authenticator.rb, line 15
def get_final_status
  critical do
    get_response('')
  end
end
send_xoauth2(auth_token) click to toggle source
# File lib/mail_xoauth2/smtp_xoauth2_authenticator.rb, line 8
def send_xoauth2(auth_token)
  critical do
    get_response("AUTH XOAUTH2 #{auth_token}")
  end
end