For a personal project, I’ve been trying to formulate a Ebay api script that pulls data on Ebay item listings. Using the freeCodeCamp API course, I’ve been working myself up the ladders of error, but now I can’t get past this error:
HTTP Error: 401 Client Error: Unauthorized for url: https://api.ebay.com/buy/browse/v1/item_summary/search?q=laptop&q=laptop
I would like to know how to debug and fix this error.
Thanks in advance!
More info:
I do get a status 200 success code on Ebays API Explorer
This is the format of my ebay_credentials.json file:
This error indicates that the request to the ebay api is not authorized. It is due to issues with your credentials.
Your ebay_credentials.json file appears to be missing the actual values for the keys app_id, cert_id, dev_id, api_endpoint, and access_token. You need to add appropriate values to these fields obtained from your ebay developer account.
Yes good u should not expose api credentials because of security reasons.
Verify that the load_credentials function correctly loads the credentials from your ebay_credentials.json file also verify environment variable of access token.
In try add print statement and verify if the headers and parameters are correctly set before making the api call. (No need to post print answer here because of security reason)
I think this looks alright, but maybe the format is off?
I’m confused with the second section of lines and don’t know how to get them to run. I know the ‘requests’ python package, but what is it requesting? How do I set this up? Mostly, I just need to know what to set the values to.
I’m not very confident in whether the api creds I’m using are the right ones, as I found the Ebay web site quite confusing. If anyone might know how these apis work, where to find the correct ones or has had success with Ebay’s api I would greatly appreciate it!
In this case the script is using the package to send a get request to ebay’s api endpoint for searching item summaries. Check if credentials expired maybe it is a reason for not working.
The only modification to the output I did was changing my actual token with my_token. The token is the only one that was actually in the output, it looks like the rest are being referred to by 'application/json'. Is this a formatting issue?