Class: GoogleSAAuth::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/google-sa-auth/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_atObject

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

#responseObject

Returns the value of attribute response.



3
4
5
# File 'lib/google-sa-auth/token.rb', line 3

def response
  @response
end

#tokenObject

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

Returns:

  • (Boolean)


11
12
13
# File 'lib/google-sa-auth/token.rb', line 11

def expired?
  Time.now.to_i >= self.expires_at
end