Код: Выделить всё
(py_venv) [myuser@rest_server bin]$ python --version
Python 3.6.8
(py_venv) [myuser@rest_server bin]$ cat /etc/redhat-release
Red Hat Enterprise Linux release 8.10 (Ootpa)
(py_venv) [myuser@rest_server bin]$ python -m requests.help
from cryptography.hazmat.bindings.openssl.binding import Binding
{
"chardet": {
"version": "5.0.0"
},
"charset_normalizer": {
"version": "2.0.12"
},
"cryptography": {
"version": "40.0.2"
},
"idna": {
"version": "3.10"
},
"implementation": {
"name": "CPython",
"version": "3.6.8"
},
"platform": {
"release": "4.18.0-553.22.1.el8_10.x86_64",
"system": "Linux"
},
"pyOpenSSL": {
"openssl_version": "30100000",
"version": "23.2.0"
},
"requests": {
"version": "2.27.1"
},
"system_ssl": {
"version": "101010bf"
},
"urllib3": {
"version": "1.26.20"
},
"using_charset_normalizer": false,
"using_pyopenssl": true
}
Код: Выделить всё
token=$(curl -s -X POST -u client_id:client_secret https://rest_server/rest-api-auth/oauth/token -H "Accept: application/json" -d "grant_type=operator_password&username=client_id&password=password&brand_key=BRAND" | cut -d ":" -f2 | cut -d "," -f1 | cut -d '"' -f2)
echo $token
Код: Выделить всё
import requests
client_id = "client_id"
client_secret = "client_secret"
username = "client_id"
password = "password"
brand = 'BRAND'
url = 'https://rest_server/rest-api-auth/oauth/token'
headers = {'accept': "application/json"}
data = {
'grant_type': 'password',
'username': f'{username}',
'password': f'{password}',
'client_id': f'{client_id}',
'client_secret': f'{client_secret}',
'brand_key': f'{brand}',
}
try:
r = requests.post(url=url,
headers=headers,
data=data, timeout=(30,30))
print(r.content)
except requests.exceptions.HTTPError as errh:
print(f"Http Error: {errh}")
except requests.exceptions.ConnectionError as errc:
print(f"Error Connecting: {errc}")
except requests.exceptions.Timeout as errt:
print(f"Timeout Error: {errt}")
except requests.exceptions.RequestException as err:
print(f"RequestException Error: {err}")
Ошибка подключения: HTTPSConnectionPool(host='rest_server', port=443): превышено максимальное количество попыток с URL-адресом: / rest-api-auth/oauth/token (вызвано SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] проверка сертификата не удалась) (_ssl.c:897)'),))
Есть идеи, в чем может быть проблема?
Подробнее здесь: https://stackoverflow.com/questions/793 ... d-ssl-c897
Мобильная версия