You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "dhillonr (via GitHub)" <gi...@apache.org> on 2025/05/14 13:58:11 UTC
Re: [D] How to send a request to the Admin REST API with a JWT token? [pulsar]
GitHub user dhillonr added a comment to the discussion: How to send a request to the Admin REST API with a JWT token?
```
import os
import pulsar
import requests
def read_token(path):
if not os.path.exists(path):
raise FileNotFoundError(f"File {path} does not exist")
with open(path, 'r') as f:
return f.read().strip()
path=<path_to_jwt_token_file>
BROKER = 'http://<ServiceURL>:<PORT>'
headers = {
"Authorization": f"Bearer {read_token(path)}"
}
response = requests.get(f'{BROKER}/admin/v2/brokers/version', headers=headers)
print("Check version:", response.status_code, response.text)
GitHub link: https://github.com/apache/pulsar/discussions/19104#discussioncomment-13145591
----
This is an automatically sent email for commits@pulsar.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@pulsar.apache.org