0

I've this code working in python, I need to convert this into nodejs but I couldn't find any equivalent code for sasl_oauth_token_provider this property.

import time
from kafka import *
from kafka.errors import KafkaTimeoutError
from oauthlib.oauth2 import BackendApplicationClient
from requests_oauthlib import OAuth2Session

producer = KafkaProducer(bootstrap_servers='xxx',
                         security_protocol='SASL_SSL',
                         ssl_check_hostname=True,
                         sasl_mechanism='OAUTHBEARER',
                         sasl_plain_username=client_id,
                         sasl_plain_password=client_secret,
                         sasl_oauth_token_provider="xxx",
                         )

For nodejs I'm using node-rdkafka library and closest equivalent code I've got is -

const kafka = require('node-rdkafka');

const producer = new kafka.Producer({
'metadata.broker.list': 'xxx',
'security.protocol': 'sasl_ssl',
'sasl.mechanism': 'OAUTHBEARER',
'sasl.username': 'xxx',
'sasl.password': 'xxx',
});
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Atiq Baqi
  • 612
  • 1
  • 7
  • 16
  • Assuming you used confluent-kafka-python and are migrating to node-rdkafka, all of the properties are the exact same.... So, what libraries are you using? – OneCricketeer Oct 17 '22 at 11:12
  • for your clarification I've modified the question please check – Atiq Baqi Oct 17 '22 at 11:52
  • I haven't used oauth, but you can find all rdkafka properties at https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md – OneCricketeer Oct 17 '22 at 13:18

1 Answers1

0

What I've found node-rdkafka has no way to sasl_oauth_token_provider use this configuration property, so I had to abandon it and use KafkaJS which supports this.

Atiq Baqi
  • 612
  • 1
  • 7
  • 16