I have generated a request in my python code to an API however it returns a 401, not authorized in the generated code and on Insomnia however it works successfully and returns a 200 when I try accessing the endpoint on my browser.
I pass the following headers
{'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.1 Safari/605.1.15', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Connection': 'keep-alive', 'Accept-Language': 'en-CA,en-US;q=0.9,en;q=0.8'}
My code is as follows:
headers = {
'User-Agent': f"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.1 Safari/605.1.15",
'Accept-Encoding': f"gzip, deflate, br",
'Accept-Language': f"en-CA,en-US;q=0.9,en;q=0.8",
'Accept': f"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
'Connection': f"keep-alive"}
self.connection.headers.update(headers)
response = self.connection.get(uri, params=payload)
return response
where self.connection is an OAuth1Session client from the requests-oauthlib library and params is an empty JSON
Any help would be appreciated!