basicAuth static method
Load a JSON file and extract BasicAuth credentials.
Throws FileSecretsError if the file is missing, malformed, or the required keys are absent.
Implementation
static Future<BasicAuth> basicAuth(
String path, {
String? section,
String usernameKey = 'username',
String passwordKey = 'password',
}) async {
final data = await _load(path, section);
final username = data[usernameKey];
final password = data[passwordKey];
if (username == null || password == null) {
throw FileSecretsError(
'Missing "$usernameKey" or "$passwordKey" in ${_desc(path, section)}',
);
}
return BasicAuth(username, password);
}