clientViaApiKey function
Obtains a Client
which uses the given apiKey
for making HTTP
requests.
If baseClient
is provided, all HTTP requests will be made with it.
Otherwise, a new Client
instance will be created.
Note that the returned client should only be used for making HTTP requests
to Google Services. The apiKey
should not be disclosed to third parties.
The user is responsible for closing the returned HTTP Client
.
Closing the returned Client
will not close baseClient
.
Implementation
Client clientViaApiKey(
String apiKey, {
Client? baseClient,
}) {
if (baseClient == null) {
baseClient = Client();
} else {
baseClient = nonClosingClient(baseClient);
}
return ApiKeyClient(baseClient, apiKey);
}