Запрос отправить с помощью запросов-OAuthlib.Python

Программы на Python
Anonymous
Запрос отправить с помощью запросов-OAuthlib.

Сообщение Anonymous »

У меня есть проблема с запросами oauthlib, в которой один из моих запросов не работает при добавлении параметров запроса. Однако тот же запрос работает над почтальником с точно такими же учетными данными и параметрами запроса. Хуже всего то, что другой набор параметров запроса не приводит к возникновению этой проблемы. < /P>
Я получаю ошибку 401 {«Сообщение»: «Подпись недействительна. Проверьте и попробуйте еще раз». }, что не должно происходить. < /p>
from requests_oauthlib import OAuth1Session

credentials = get_credentials() # get credentials from env variable (they are OK !)
connection = OAuth1Session(credentials.consumer_key, credentials.consumer_secret, credentials.access_token, credentials.access_token_secret, signature_method="HMAC-SHA256")

page_size = 1000
page_number = 1

query = {
"searchCriteria[pageSize]": page_size,
"searchCriteria[currentPage]": page_number,
"searchCriteria[filterGroups][0][filters][0][conditionType]": "gt",
"searchCriteria[filterGroups][0][filters][0][field]": "updated_at",
"searchCriteria[filterGroups][0][filters][0][value]": "1900-01-01 00:00:00",
}

response = connection.get("an url", params=query) #this request will fail but succeed on postman
< /code>
from requests_oauthlib import OAuth1Session

credentials = get_credentials() # get credentials from env variable (they are OK !)
connection = OAuth1Session(credentials.consumer_key, credentials.consumer_secret, credentials.access_token, credentials.access_token_secret, signature_method="HMAC-SHA256")

page_size = 1000
page_number = 1

query = {
"searchCriteria[pageSize]": page_size,
"searchCriteria[currentPage]": page_number,
"searchCriteria[filterGroups][0][filters][0][conditionType]": "eq",
"searchCriteria[filterGroups][0][filters][0][field]": "visibility",
"searchCriteria[filterGroups][0][filters][0][value]": 4,
}

response = connection.get("an url", params=query) #this request will succeed, wtf ???
< /code>
I tried ordering the parameters using a orderedDict. I checked my credentials. I checked different query parameters (they are working as intended) and I checked my failing query with postman and it is working as intended (no failure).

Подробнее здесь: https://stackoverflow.com/questions/793 ... on-postman

Вернуться в «Python»