-
This document assumes that you have created a service account, and have granted the service account
produce
andconsume
permissions to the namespace for the target topic. -
You need to install Python 3.0 or higher and the Pulsar Python client. Use the following command to install the Python client:
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.
SERVICE_URL
: the broker service URL of your Pulsar cluster.AUTH_PARAMS
: the token of your service account.
-
Create a Python consumer and use the Python consumer to consume messages.
-
Create a Python producer and use the Python 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.
-
Expose your authentication credentials.
issuer_url
: the URL of your OAuth2 identity provider.private_key
: the path to your OAuth2 credential file.audience
: theaudience
of your Pulsar cluster.
-
Connect to a Pulsar cluster through the OAuth2 credential file.
-
Create a Python consumer and use the Python consumer to consume messages.
-
Create a Python producer and use the Python producer to produce messages.