// Module included in the following module:
//
// con-oauth-config.adoc

[id='proc-oauth-client-config-{context}']
= Setting up OAuth 2.0 on Kafka Java clients

[role="_abstract"]
Configure Kafka producer and consumer APIs to use OAuth 2.0 for interaction with Kafka brokers.
Add a callback plugin to your client `pom.xml` file, then configure your client for OAuth 2.0.

How you configure the authentication properties depends on the authentication method you are using to access the OAuth 2.0 authorization server.
In this procedure, the properties are specified in a properties file, then loaded into the client configuration.

.Prerequisites

* Strimzi and Kafka are running
* An OAuth 2.0 authorization server is deployed and configured for OAuth access to Kafka brokers
* Kafka brokers are configured for OAuth 2.0

.Procedure

. Add the client library with OAuth 2.0 support to the `pom.xml` file for the Kafka client:
+
[source,xml,subs="+attributes"]
----
<dependency>
 <groupId>io.strimzi</groupId>
 <artifactId>kafka-oauth-client</artifactId>
 <version>{OAuthVersion}</version>
</dependency>
----

. Configure the client depending on the OAuth 2.0 authentication method:
+
--
* xref:con-oauth-authentication-client-credentials-{context}[]
* xref:con-oauth-authentication-password-grants-{context}[]
* xref:con-oauth-authentication-access-token-{context}[]
* xref:con-oauth-authentication-refresh-token-{context}[]
--
+
For example, specify the properties for the authentication method in a `client.properties` file.

. Input the client properties for OAUTH 2.0 authentication into the Java client code.
+
.Example showing input of client properties
[source,java,subs="+quotes,attributes"]
----
Properties props = new Properties();
try (FileReader reader = new FileReader("client.properties", StandardCharsets.UTF_8)) {
  props.load(reader);
}
----

. Verify that the Kafka client can access the Kafka brokers.

