Skip to content

Add OAuth bearer token refresh callback support#322

Open
kalavt wants to merge 2 commits intomfontanini:masterfrom
kalavt:oauth-callback-pointer-fix
Open

Add OAuth bearer token refresh callback support#322
kalavt wants to merge 2 commits intomfontanini:masterfrom
kalavt:oauth-callback-pointer-fix

Conversation

@kalavt
Copy link

@kalavt kalavt commented Feb 26, 2026

This PR adds support for OAuth bearer token refresh callbacks, enabling authentication mechanisms like AWS MSK IAM, Azure Event Hubs, and custom OAuth implementations.

Changes:

  • Add OAuthBearerTokenRefreshCallback support to Configuration class
  • Implement callback proxy for rd_kafka_conf_set_oauthbearer_token_refresh_cb
  • Add comprehensive documentation and example
  • Use pointer parameter for semantic consistency with librdkafka

Implementation Details:

The callback uses const std::string* instead of const std::string& to maintain semantic consistency with librdkafka, allowing callers to distinguish between:

  • Config not set (nullptr)
  • Config set to empty string ("")

Testing:

Includes complete example implementation in examples/oauth_example.cpp

Change the oauthbearer_config parameter from 'const std::string&' to
'const std::string*' to maintain semantic consistency with librdkafka.

This allows the callback to distinguish between:
- Config not set (nullptr)
- Config set to empty string ('')

Updated files:
- include/cppkafka/configuration.h: Changed callback signature
- src/configuration.cpp: Modified proxy to pass nullptr instead of empty string
- examples/oauth_example.cpp: Updated example to check for nullptr
- docs/oauth_bearer_callback.md: Updated all documentation and examples

Addresses PR review comment from antaljanosbenjamin.
@kalavt
Copy link
Author

kalavt commented Feb 26, 2026

@mfontanini would you pls review the changes, for add oauth refresh callback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant