Class: Gmail::Authenticator
- Inherits:
-
Object
- Object
- Gmail::Authenticator
- Defined in:
- lib/gmail/authenticator.rb
Defined Under Namespace
Classes: ImapBackupToken, MalformedImapBackupToken
Constant Summary collapse
- GMAIL_READ_SCOPE =
"https://mail.google.com/".freeze
- OOB_URI =
"urn:ietf:wg:oauth:2.0:oob".freeze
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
- #authorization_url ⇒ Object
- #credentials ⇒ Object
- #credentials_from_code(code) ⇒ Object
-
#initialize(email:, token:) ⇒ Authenticator
constructor
A new instance of Authenticator.
Constructor Details
#initialize(email:, token:) ⇒ Authenticator
Returns a new instance of Authenticator.
82 83 84 85 |
# File 'lib/gmail/authenticator.rb', line 82 def initialize(email:, token:) @email = email @token = token end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
75 76 77 |
# File 'lib/gmail/authenticator.rb', line 75 def email @email end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
76 77 78 |
# File 'lib/gmail/authenticator.rb', line 76 def token @token end |
Class Method Details
.refresh_token?(text) ⇒ Boolean
78 79 80 |
# File 'lib/gmail/authenticator.rb', line 78 def self.refresh_token?(text) ImapBackupToken.new(text).valid? end |
Instance Method Details
#authorization_url ⇒ Object
87 88 89 |
# File 'lib/gmail/authenticator.rb', line 87 def .(base_url: OOB_URI) end |
#credentials ⇒ Object
91 92 93 94 95 |
# File 'lib/gmail/authenticator.rb', line 91 def credentials .get_credentials(email).tap do |c| c.refresh! if c.expired? end end |
#credentials_from_code(code) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/gmail/authenticator.rb', line 97 def credentials_from_code(code) .get_credentials_from_code( user_id: email, code: code, base_url: OOB_URI ) end |