Class: CognitoIdp::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/cognito_idp/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token_hash) ⇒ Token

Returns a new instance of Token.



7
8
9
10
11
12
13
14
15
# File 'lib/cognito_idp/token.rb', line 7

def initialize(token_hash)
  token_hash.transform_keys(&:to_sym).tap do |values|
    @access_token = values[:access_token]
    @id_token = values[:id_token]
    @token_type = values[:token_type]
    @expires_in = values[:expires_in]
  end
  @expires_at = Time.now + expires_in unless expires_in.nil?
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



5
6
7
# File 'lib/cognito_idp/token.rb', line 5

def access_token
  @access_token
end

#expires_atObject (readonly)

Returns the value of attribute expires_at.



5
6
7
# File 'lib/cognito_idp/token.rb', line 5

def expires_at
  @expires_at
end

#expires_inObject (readonly)

Returns the value of attribute expires_in.



5
6
7
# File 'lib/cognito_idp/token.rb', line 5

def expires_in
  @expires_in
end

#id_tokenObject (readonly)

Returns the value of attribute id_token.



5
6
7
# File 'lib/cognito_idp/token.rb', line 5

def id_token
  @id_token
end

#token_typeObject (readonly)

Returns the value of attribute token_type.



5
6
7
# File 'lib/cognito_idp/token.rb', line 5

def token_type
  @token_type
end