Representation of an application's identity for user authorization flows.
Text identifier of the client ID @return [String]
Secret associated with the client ID @return [String]
Constructs a Client ID from a JSON file downloaed from the Google Developers Console.
@param [String, File] file
Path of file to read from
@return [Google::Auth::ClientID]
# File lib/googleauth/client_id.rb, line 78 def self.from_file(file) raise 'File can not be nil.' if file.nil? File.open(file.to_s) do |f| json = f.read config = MultiJson.load(json) from_hash(config) end end
Constructs a Client ID from a previously loaded JSON file. The hash structure should match the expected JSON format.
@param [hash] config
Parsed contents of the JSON file
@return [Google::Auth::ClientID]
# File lib/googleauth/client_id.rb, line 94 def self.from_hash(config) raise 'Hash can not be nil.' if config.nil? raw_detail = config[INSTALLED_APP] || config[WEB_APP] raise MISSING_TOP_LEVEL_ELEMENT_ERROR if raw_detail.nil? ClientId.new(raw_detail[CLIENT_ID], raw_detail[CLIENT_SECRET]) end
Initialize the Client ID
@param [String] id
Text identifier of the client ID
@param [String] secret
Secret associated with the client ID
@note Direction instantion is discouraged to avoid embedding IDs
& secrets in source. See {#from_file} to load from `client_secrets.json` files.
# File lib/googleauth/client_id.rb, line 65 def initialize(id, secret) raise 'Client id can not be nil' if id.nil? raise 'Client secret can not be nil' if secret.nil? @id = id @secret = secret end