I have this configuration in file kafka_jaas.conf:
KafkaClient {
org.apache.kafka.common.security.plain.PlainLoginModule required
oauth.token.endpoint.uri="uri"
oauth.client.id="uid"
oauth.client.secret="secret";
};
And add it to client configuration like this:
client-config {
bootstrap.servers = ${bootstrap.servers}
schema.registry.url = ${schema.registry.url}
security{
protocol = "SASL_PLAINTEXT"
sasl.mechanism = "OAUTHBEARER"
sasl.jaas.config = "absolute/path/to/kafka_jaas.conf"
}
}
But I got this error:
Exception in thread "main" org.apache.kafka.common.KafkaException: Failed to create new KafkaAdminClient
...
Caused by: java.lang.IllegalArgumentException: Could not find a 'KafkaClient' entry in the JAAS configuration. System property 'java.security.auth.login.config' is not set
Can I fix it without adding system property manually just by using configuration files?
You can add System.setProperty("java.security.auth.login.config",...)
at runtime by parsing your config. It won't be automatic. But if you have access to the deployment environment, using JVM flags is more preferable