Blizzard / node-rdkafka

Node.js bindings for librdkafka
MIT License
2.1k stars 390 forks source link

How to provide token for SASL_SSL explicitly? #1026

Closed andrewstanovsky closed 4 months ago

andrewstanovsky commented 1 year ago

I'm trying to migrate my KafkaJS code to Node-RdKafka but I couldn't find an equivalent.

KafkaJS snippet:

    const kafka = new Kafka({
        clientId: "test-producer",
        brokers: ['<broker_fqdn_port>'],
        ssl: true,
        sasl: {
            mechanism: 'oauthbearer',
            oauthBearerProvider: async () => {
                return {
                    value: token
                }
            },
        }
    });

I'm getting token outside of the kafka client and plan to refresh it using this token provider approach. I was trying to find the same mechanism in Node-RdKafka but with no success. I've also tried oauthbearer_token_refresh_cb but it looks like it's called much later than initial connect() call.

Please, let me know if it's even possible with the latest version at all

andrewstanovsky commented 4 months ago

The workaround has been merged in and is available in ^3.0.1:

https://github.com/Blizzard/node-rdkafka/commit/f594d1138b0435a0e73dd563828faa6dcad39bc3