Class: Gmail::Authenticator
- Inherits:
-
Object
- Object
- Gmail::Authenticator
show all
- 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
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(email:, token:) ⇒ 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
Returns the value of attribute email.
75
76
77
|
# File 'lib/gmail/authenticator.rb', line 75
def email
@email
end
|
#token ⇒ Object
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 authorization_url
authorizer.get_authorization_url(base_url: OOB_URI)
end
|
#credentials ⇒ Object
91
92
93
94
95
|
# File 'lib/gmail/authenticator.rb', line 91
def credentials
authorizer.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)
authorizer.get_credentials_from_code(
user_id: email,
code: code,
base_url: OOB_URI
)
end
|