Class: Gmail::Client::XOAuth
Constant Summary
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)
-
- (Object) consumer_key
readonly
Returns the value of attribute consumer_key.
-
- (Object) consumer_secret
readonly
Returns the value of attribute consumer_secret.
-
- (Object) secret
readonly
Returns the value of attribute secret.
-
- (Object) token
readonly
Returns the value of attribute token.
Attributes inherited from Base
Instance Method Summary (collapse)
-
- (XOAuth) initialize(username, options = {})
constructor
A new instance of XOAuth.
- - (Object) login(raise_errors = false)
- - (Object) smtp_settings
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
- (XOAuth) initialize(username, options = {})
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
- (Object) consumer_key (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 |
- (Object) consumer_secret (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 |
- (Object) secret (readonly)
Returns the value of attribute secret
7 8 9 |
# File 'lib/gmail/client/xoauth.rb', line 7 def secret @secret end |
- (Object) token (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
- (Object) login(raise_errors = false)
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 |
- (Object) smtp_settings
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 => secret = { :consumer_key => consumer_key, :consumer_secret => consumer_secret, :token => token, :token_secret => token_secret }, :authentication => :xoauth, :enable_starttls_auto => true }] end |