Class: GoogleSAAuth::Token
- Inherits:
-
Object
- Object
- GoogleSAAuth::Token
- Defined in:
- lib/google-sa-auth/token.rb
Instance Attribute Summary collapse
-
#expires_at ⇒ Object
Returns the value of attribute expires_at.
-
#response ⇒ Object
Returns the value of attribute response.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(jwt) ⇒ Token
constructor
A new instance of Token.
Constructor Details
#initialize(jwt) ⇒ Token
Returns a new instance of Token.
4 5 6 7 8 9 |
# File 'lib/google-sa-auth/token.rb', line 4 def initialize(jwt) # Get the token upon initialization and symbolize the keys. self.response = get_auth_token(jwt.jwt).inject({}){|item,(k,v)| item[k.to_sym] = v; item} self.token = self.response[:access_token] self.expires_at = jwt.claim_set[:exp] end |
Instance Attribute Details
#expires_at ⇒ Object
Returns the value of attribute expires_at.
3 4 5 |
# File 'lib/google-sa-auth/token.rb', line 3 def expires_at @expires_at end |
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/google-sa-auth/token.rb', line 3 def response @response end |
#token ⇒ Object
Returns the value of attribute token.
3 4 5 |
# File 'lib/google-sa-auth/token.rb', line 3 def token @token end |
Instance Method Details
#expired? ⇒ Boolean
11 12 13 |
# File 'lib/google-sa-auth/token.rb', line 11 def expired? Time.now.to_i >= self.expires_at end |