authenticatedClient function
AuthClient
authenticatedClient(
- Client baseClient,
- AccessCredentials credentials, {
- bool closeUnderlyingClient = false,
Obtain a Client which automatically authenticates requests using
credentials.
Note that the returned AuthClient will not auto-refresh the given
credentials.
The user is responsible for closing the returned HTTP Client.
If closeUnderlyingClient is true, AuthClient.close will also close
baseClient.
Closing the returned Client will not close baseClient.
Implementation
AuthClient authenticatedClient(
Client baseClient,
AccessCredentials credentials, {
bool closeUnderlyingClient = false,
}) {
if (credentials.accessToken.type != 'Bearer') {
throw ArgumentError('Only Bearer access tokens are accepted.');
}
return AuthenticatedClient(
baseClient,
credentials,
closeUnderlyingClient: closeUnderlyingClient,
);
}