This document assumes that you have created a service account, and have granted the service account
produce and consume permissions to the namespace for the target topic.Connect to a Pulsar cluster using a token
This section describes how to connect to you Pulsar cluster using a token.Prerequisites
Steps
To connect to your Pulsar cluster using a token, follow these steps.-
Connect to the Pulsar cluster.
Set the
serviceUrlandtokenparameters based on the descriptions in the prepare to connect to a Pulsar cluster user guide. -
Create a Node.js consumer and use the Node.js consumer to consume messages.
-
Create a Node.js producer and use the Node.js producer to produce messages.
Connect to a Pulsar cluster using an OAuth2 credential file
To connect to your Pulsar cluster using an OAuth2 credential file, follow these steps.- Generate the App credentials by following similar instructions in configure OAuth2 authentication.
- Save the App credentials into an OAuth2 credential file.
-
Connect to a Pulsar cluster through the OAuth2 credential file.
issuer_url: the URL of your OAuth2 identity provider.private_key: the path to your OAuth2 credential file.client_id: the Pulsar application client ID.client_secret: the Pulsar application client secret.audience: theaudienceof your Pulsar cluster.serviceUrl: the URL of your Pulsar cluster.
-
Create a Node.js consumer and use the Node.js consumer to consume messages.
-
Create a Node.js producer and use the Node.js producer to produce messages.