Module: GmailXoauth::SmtpXoauth2Authenticator

Includes:
OauthString
Defined in:
lib/gmail_xoauth/smtp_xoauth2_authenticator.rb

Instance Method Summary collapse

Instance Method Details

#auth_xoauth2(user, oauth2_token) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gmail_xoauth/smtp_xoauth2_authenticator.rb', line 21

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
  if res.continue?
    res = get_final_status
  end
  
  check_auth_response res
  res
end