Method: Google::Auth::ClientId.from_hash

Defined in:
lib/googleauth/client_id.rb

.from_hash(config) ⇒ Google::Auth::ClientID

Constructs a Client ID from a previously loaded JSON file. The hash structure should match the expected JSON format.

Parameters:

  • config (hash)

    Parsed contents of the JSON file

Returns:

  • (Google::Auth::ClientID)

Raises:



102
103
104
105
106
107
# File 'lib/googleauth/client_id.rb', line 102

def self.from_hash config
  raise InitializationError, "Hash can not be nil." if config.nil?
  raw_detail = config[INSTALLED_APP] || config[WEB_APP]
  raise InitializationError, MISSING_TOP_LEVEL_ELEMENT_ERROR if raw_detail.nil?
  ClientId.new raw_detail[CLIENT_ID], raw_detail[CLIENT_SECRET]
end