setAuthenticate method

  1. @override
void setAuthenticate(
  1. Future<bool> f(
    1. Uri url,
    2. String scheme,
    3. String? realm
    )?
)
override

Sets the function to be called when a site is requesting authentication.

Pass through setter of HttpClient.authenticate. This callback called when server returns Unauthorized (401). addCredentials can be called in this callback method to authorize client. Return false when authorization cannot be provided."

Example:

client.setAuthenticate((url, scheme, realm) {
  client.addCredentials(...);
  return Future.value(true);
});

Implementation

@override
void setAuthenticate(
        Future<bool> Function(Uri url, String scheme, String? realm)? f) =>
    client.authenticate = f;