-
Notifications
You must be signed in to change notification settings - Fork 398
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 flow
- Loading branch information
1 parent
c862a54
commit 4adbd7d
Showing
12 changed files
with
253 additions
and
5 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
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
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.