Class: SimpleGoogleAuth::AuthDataPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_google_auth/auth_data_presenter.rb

Constant Summary collapse

InvalidAuthDataError =
Class.new(Error)
FIELDS =
%w(
  access_token
  expires_in
  token_type
  refresh_token
  id_token
  iss
  at_hash
  email_verified
  sub
  azp
  email
  aud
  iat
  exp
  hd
  expires_at
)

Instance Method Summary collapse

Constructor Details

#initialize(auth_data) ⇒ AuthDataPresenter

Returns a new instance of AuthDataPresenter.



24
25
26
27
28
29
# File 'lib/simple_google_auth/auth_data_presenter.rb', line 24

def initialize(auth_data)
  raise InvalidAuthDataError if auth_data["id_token"].nil?

  token_data = unpack_json_web_token(auth_data["id_token"])
  @data = auth_data.merge(token_data)
end

Instance Method Details

#[](field) ⇒ Object



31
32
33
# File 'lib/simple_google_auth/auth_data_presenter.rb', line 31

def [](field)
  @data[field.to_s]
end