Class: Gmail::Client::XOAuth
Constant Summary
Constants inherited from Base
Base::GMAIL_IMAP_HOST, Base::GMAIL_IMAP_PORT, Base::GMAIL_SMTP_HOST, Base::GMAIL_SMTP_PORT
Instance Attribute Summary collapse
-
#consumer_key ⇒ Object
readonly
Returns the value of attribute consumer_key.
-
#consumer_secret ⇒ Object
readonly
Returns the value of attribute consumer_secret.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(username, options = {}) ⇒ XOAuth
constructor
A new instance of XOAuth.
- #login(raise_errors = false) ⇒ Object
- #smtp_settings ⇒ Object
Methods inherited from Base
#compose, #connect, #connect!, #connection, #deliver, #deliver!, #fill_username, #inbox, #inspect, #labels, #logged_in?, #login!, #logout, #mail_domain, #mailbox, #mailboxes
Constructor Details
#initialize(username, options = {}) ⇒ XOAuth
Returns a new instance of XOAuth.
11 12 13 14 15 16 17 18 |
# File 'lib/gmail/client/xoauth.rb', line 11 def initialize(username, ={}) @token = .delete(:token) @secret = .delete(:secret) @consumer_key = .delete(:consumer_key) @consumer_secret = .delete(:consumer_secret) super(username, ) end |
Instance Attribute Details
#consumer_key ⇒ Object (readonly)
Returns the value of attribute consumer_key.
8 9 10 |
# File 'lib/gmail/client/xoauth.rb', line 8 def consumer_key @consumer_key end |
#consumer_secret ⇒ Object (readonly)
Returns the value of attribute consumer_secret.
9 10 11 |
# File 'lib/gmail/client/xoauth.rb', line 9 def consumer_secret @consumer_secret end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
7 8 9 |
# File 'lib/gmail/client/xoauth.rb', line 7 def secret @secret end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/gmail/client/xoauth.rb', line 6 def token @token end |
Instance Method Details
#login(raise_errors = false) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gmail/client/xoauth.rb', line 20 def login(raise_errors=false) @imap and @logged_in = (login = @imap.authenticate('XOAUTH', username, :consumer_key => consumer_key, :consumer_secret => consumer_secret, :token => token, :token_secret => secret )) && login.name == 'OK' rescue raise_errors and raise AuthorizationError, "Couldn't login to given GMail account: #{username}" end |
#smtp_settings ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gmail/client/xoauth.rb', line 31 def smtp_settings [:smtp, { :address => GMAIL_SMTP_HOST, :port => GMAIL_SMTP_PORT, :domain => mail_domain, :user_name => username, :password => { :consumer_key => consumer_key, :consumer_secret => consumer_secret, :token => token, :token_secret => secret }, :authentication => :xoauth, :enable_starttls_auto => true }] end |