Reference documentation and code samples for the googleauth class Google::Auth::APIKeyCredentials.
Implementation of Google API Key authentication.
API Keys are text strings. They don't have an associated JSON file.
The end-user is managing their API Keys directly, not via an authentication library.
API Keys provide project information for an API request. API Keys don't reference an IAM principal, they do not expire, and cannot be refreshed.
Inherits
- Object
Includes
Methods
.from_env
def self.from_env(_scope = nil, options = {}) -> Google::Auth::APIKeyCredentials, nil
Creates an APIKeyCredentials from the environment. Checks the ENV['GOOGLE_API_KEY'] variable.
- _scope (String) — The scope to use for OAuth. Not used by API key auth.
- options (Hash) — The options to pass to the credentials instance
- (Google::Auth::APIKeyCredentials, nil) — Credentials if the API key environment variable is present, nil otherwise
.make_creds
def self.make_creds(options = {}) -> Google::Auth::APIKeyCredentials
Create the APIKeyCredentials.
- options (Hash) — The credentials options
#api_key
def api_key() -> String
- (String) — The API key
#apply!
def apply!(a_hash, _opts = {}) -> Hash
Updates the provided hash with the API Key header.
The apply!
method modifies the provided hash in place, adding the
x-goog-api-key
header with the API Key value.
The API Key is hashed before being logged for security purposes.
NB: this method typically would be called through updater_proc
.
Some older clients call it directly though, so it has to be public.
- a_hash (Hash) — The hash to which the API Key header should be added. This is typically a hash representing the request headers. This hash will be modified in place.
-
_opts (Hash) — Additional options (currently not used). Included
for consistency with the
BaseClient
interface.
-
(Hash) — The modified hash (the same hash passed as the
a_hash
argument).
#duplicate
def duplicate(options = {}) -> Google::Auth::APIKeyCredentials
Creates a duplicate of these credentials.
- options (Hash) — Additional options for configuring the credentials
#expires_within?
def expires_within?(_seconds) -> Boolean
Determines if the credentials object has expired. Since API keys don't expire, this always returns false.
- _seconds (Fixnum) — The optional timeout in seconds since the last refresh
- (Boolean) — True if the token has expired, false otherwise.
#initialize
def initialize(options = {}) -> APIKeyCredentials
Initialize the APIKeyCredentials.
- options (Hash) — The credentials options
- (APIKeyCredentials) — a new instance of APIKeyCredentials
- (ArgumentError)
#universe_domain
def universe_domain() -> String
- (String) — The universe domain of the universe this API key is for
#universe_domain=
def universe_domain=(value) -> String
- value (String) — The universe domain of the universe this API key is for
- (String) — The universe domain of the universe this API key is for