Method: Signet::OAuth2::Client#decoded_id_token

Defined in:
lib/signet/oauth_2/client.rb

#decoded_id_token(public_key = nil, options = {}) ⇒ String

Returns the decoded ID token associated with this client.



711
712
713
714
715
716
717
718
719
720
# File 'lib/signet/oauth_2/client.rb', line 711

def decoded_id_token(public_key=nil, options = {})
  payload, _header = JWT.decode(self.id_token, public_key, !!public_key, options)
  if !payload.has_key?('aud')
    raise Signet::UnsafeOperationError, 'No ID token audience declared.'
  elsif payload['aud'] != self.client_id
    raise Signet::UnsafeOperationError,
      'ID token audience did not match Client ID.'
  end
  return payload
end