401 in item summary search via python, but valid using postman
Summary: d.cook is experiencing an issue with using the eBay API to retrieve item summary information. While they successfully obtain a JWT token and make API requests in Postman, they encounter a 401 error when implementing the same process in a Python script. Despite using the same token from the Python script in Postman successfully, the Python requests return 'Invalid access token' errors. d.cook seeks advice on what might be going wrong, noting no significant differences in the request headers or parameters between the two methods.
Here is my problem. As a beginner with the EBay API, I started testing in the sandbox using postman to understand how to obtain a JWT token. Then use the obtained token as the Bearer Token in follow on GET request for the item summary information.
All went well when creating the token request in postman and also using that token in another postman GET request to get the item summary data.
Next, I try the same in a python script. The request to retrieve the token works as expected, but when the generated token is used in the request for the item summary, the result is a 401 error. The strange part is I can copy the token value obtained from the python script (from the log), paste it into the postman query, and the result is postman gets a 200 with the expected data returned. So the generation of the token does not seem to be the problem.
From the python script response I am logging the request.url, request.headers, and request.body and see the following in the log:
https://api.ebay.com/buy/browse/v1/item_summary/search?q=Phone&limit=20
I also log the response.status_code and the response.text and see the following:
401 - {
"errors": [
{
"errorId": 1001,
"domain": "OAuth",
"category": "REQUEST",
"message": "Invalid access token",
"longMessage": "Invalid access token. Check the value of the Authorization HTTP request header."
}
]
}
I can take the same token logged above, paste it into a postman GET request to the same URL and a 200 status code is returned with the correct data.
I do not see any significant difference in the headers or parameters sent from either postman or python script. What am I missing?