class Google::Auth::APIKeyCredentials
and cannot be refreshed.
API Keys don’t reference an IAM principal, they do not expire,
API Keys provide project information for an API request.
an authentication library.
The end-user is managing their API Keys directly, not via
API Keys are text strings. They don’t have an associated JSON file.
Implementation of Google API Key authentication.
#
def apply! a_hash, _opts = {}
-
(Hash)- The modified hash (the same hash passed as the `a_hash`
Parameters:
-
_opts(Hash) -- Additional options (currently not used). Included -
a_hash(Hash) -- The hash to which the API Key header should be added.
def apply! a_hash, _opts = {} a_hash[API_KEY_HEADER] = @api_key logger&.debug do hash = Digest::SHA256.hexdigest @api_key Google::Logging::Message.from message: "Sending API key auth token. (sha256:#{hash})" end a_hash end
def duplicate options = {}
-
(Google::Auth::APIKeyCredentials)-
Parameters:
-
options(Hash) -- Additional options for configuring the credentials
def duplicate options = {} self.class.new( api_key: options[:api_key] || @api_key, universe_domain: options[:universe_domain] || @universe_domain ) end
def expires_within? _seconds
-
(Boolean)-
Parameters:
-
_seconds(Fixnum) --
def expires_within? _seconds false end
def fetch_access_token! _options = {}
def fetch_access_token! _options = {} nil end
def from_env _scope = nil, options = {}
-
(Google::Auth::APIKeyCredentials, nil)-
Parameters:
-
options(Hash) -- -
_scope(String) --
def from_env _scope = nil, options = {} api_key = ENV[API_KEY_VAR] return nil if api_key.nil? || api_key.empty? new options.merge(api_key: api_key) end
def initialize options = {}
-
(ArgumentError)- If the API key is nil or empty
Options Hash:
(**options)-
:universe_domain(String) -- -
:api_key(String) --
Parameters:
-
options(Hash) -- The credentials options
def initialize options = {} raise ArgumentError, "API key must be provided" if options[:api_key].nil? || options[:api_key].empty? @api_key = options[:api_key] @universe_domain = options[:universe_domain] || "googleapis.com" end
def make_creds options = {}
-
(Google::Auth::APIKeyCredentials)-
Options Hash:
(**options)-
:universe_domain(String) -- -
:api_key(String) --
Parameters:
-
options(Hash) -- The credentials options
def make_creds options = {} new options end
def principal
-
(Symbol)- the token type in lieu of the principal
Other tags:
- Private: -
def principal token_type end
def token_type
def token_type :api_key end