-
Notifications
You must be signed in to change notification settings - Fork 396
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add setToken API for OAuthBearer authentication flow (#1075)
- Loading branch information
1 parent
a0648d3
commit f594d11
Showing
14 changed files
with
328 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
Producer, Consumer and HighLevelProducer: | ||
```js | ||
/* | ||
* node-rdkafka - Node.js wrapper for RdKafka C/C++ library | ||
* | ||
* Copyright (c) 2016 Blizzard Entertainment | ||
* | ||
* This software may be modified and distributed under the terms | ||
* of the MIT license. See the LICENSE.txt file for details. | ||
*/ | ||
|
||
var Kafka = require('../'); | ||
|
||
var token = "your_token"; | ||
|
||
var producer = new Kafka.Producer({ | ||
//'debug' : 'all', | ||
'metadata.broker.list': 'localhost:9093', | ||
'security.protocol': 'SASL_SSL', | ||
'sasl.mechanisms': 'OAUTHBEARER', | ||
}).setOauthBearerToken(token); | ||
|
||
//start the producer | ||
producer.connect(); | ||
|
||
//refresh the token | ||
producer.setOauthBearerToken(token); | ||
``` | ||
|
||
AdminClient: | ||
```js | ||
/* | ||
* node-rdkafka - Node.js wrapper for RdKafka C/C++ library | ||
* | ||
* Copyright (c) 2016 Blizzard Entertainment | ||
* | ||
* This software may be modified and distributed under the terms | ||
* of the MIT license. See the LICENSE.txt file for details. | ||
*/ | ||
var Kafka = require('../'); | ||
|
||
var token = "your_token"; | ||
|
||
var admin = Kafka.AdminClient.create({ | ||
'metadata.broker.list': 'localhost:9093', | ||
'security.protocol': 'SASL_SSL', | ||
'sasl.mechanisms': 'OAUTHBEARER', | ||
}, token); | ||
|
||
//refresh the token | ||
admin.refreshOauthBearerToken(token); | ||
``` | ||
|
||
ConsumerStream: | ||
```js | ||
/* | ||
* node-rdkafka - Node.js wrapper for RdKafka C/C++ library | ||
* | ||
* Copyright (c) 2016 Blizzard Entertainment | ||
* | ||
* This software may be modified and distributed under the terms | ||
* of the MIT license. See the LICENSE.txt file for details. | ||
*/ | ||
var Kafka = require('../'); | ||
|
||
var token = "your_token"; | ||
|
||
var stream = Kafka.KafkaConsumer.createReadStream({ | ||
'metadata.broker.list': 'localhost:9093', | ||
'group.id': 'myGroup', | ||
'security.protocol': 'SASL_SSL', | ||
'sasl.mechanisms': 'OAUTHBEARER' | ||
}, {}, { | ||
topics: 'test1', | ||
initOauthBearerToken: token, | ||
}); | ||
|
||
//refresh the token | ||
stream.refreshOauthBearerToken(token.token); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.