You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/12/29 08:55:41 UTC
[GitHub] [pulsar] Christopher-06 created a discussion: How to send a request to the Admin REST API with a JWT token?
GitHub user Christopher-06 created a discussion: How to send a request to the Admin REST API with a JWT token?
Hello together,
I am trying to configure my Pulsar cluster and wanted to create a Python script for it. But since I have JWT token enabled for security reasons, it needs to be sent along to the REST API, but I don't know where it needs to be set.
Does anyone here know more specific?
Cheers!
GitHub link: https://github.com/apache/pulsar/discussions/19104
----
This is an automatically sent email for commits@pulsar.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@pulsar.apache.org
Re: [D] How to send a request to the Admin REST API with a JWT token? [pulsar]
Posted by "dhillonr (via GitHub)" <gi...@apache.org>.
GitHub user dhillonr edited a comment on the discussion: How to send a request to the Admin REST API with a JWT token?
```
import os
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
[GitHub] [pulsar] yangl added a comment to the discussion: How to send a request to the Admin REST API with a JWT token?
Posted by GitBox <gi...@apache.org>.
GitHub user yangl added a comment to the discussion: How to send a request to the Admin REST API with a JWT token?
curl -X GET -H 'Authorization: Bearer JTW_TOKEN(NO token: prefix)' -H 'X-Pulsar-Auth-Method-Name: token' -H 'Content-Type: application/json; charset=UTF-8' -i 'http://ServiceURL:PORT/admin/v2/persistent/public/default/partitioned?includeSystemTopic=false'
GitHub link: https://github.com/apache/pulsar/discussions/19104#discussioncomment-5085326
----
This is an automatically sent email for commits@pulsar.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@pulsar.apache.org
Re: [D] How to send a request to the Admin REST API with a JWT token? [pulsar]
Posted by "dhillonr (via GitHub)" <gi...@apache.org>.
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