-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Hi and thanks for making this library!
We are exploring to use brod_oauth for SASL/OAUTHBEARER authentication towards Kafka. Our JWT tokens are valid for 30 minutes, and it works fine to connect to Kafka while the token is valid. However, after the token expires, we get errors like this, which are only resolved by an application restart:
exception error: {sasl_auth_error,<<"Token expired at: 1742309468000 (2025-03-18T14:51:08 UTC) (ErrId: 2791d48d)">>}Looking at the code in brod_oauth, my understanding is that tokens are only used to establish a connection, but that connections may live longer than the corresponding token, and that tokens for a given connection don't get refreshed dynamically. Is that correct?
Any help would be much appreciated!
Our Config
Our brod config looks like this:
{brod, [
{clients, [
{client_name, [
{endpoints, [{"${KAFKA_HOST}", ${KAFKA_PORT}}]},
{ssl, true},
{sasl, {callback, brod_oauth, #{token_callback => fun module:callback/1}}}
]}
]}
]}And a call to module:callback/1 returns the following, where Token is a JWT access token:
{ok, #{token => Token}}Subsequent calls to module:callback/1 return the same token as long as the token is not expired, and a new token after the token expires.