[formatting: edited by admin]
amazon = bottlenose.Amazon(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_ASSOCIATE_TAG, Region='US')
response = amazon.ItemSearch(Keywords="Kindle 3G", SearchIndex="All")
The above code runs successfully and returns valid response.
amazon = bottlenose.Amazon(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_ASSOCIATE_TAG, Region='IN')
response = amazon.ItemSearch(Keywords="Kindle 3G", SearchIndex="All")
The above code fails with an 403 response code. The only difference is the region is changed from US to IN. The following is the traceback:
2017-11-30 10:29:34,370: Traceback (most recent call last):
2017-11-30 10:29:34,370: File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1988, in wsgi_app
2017-11-30 10:29:34,370: response = self.full_dispatch_request()
2017-11-30 10:29:34,370: File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1641, in full_dispatch_request
2017-11-30 10:29:34,370: rv = self.handle_user_exception(e)
2017-11-30 10:29:34,371: File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1544, in handle_user_exception
2017-11-30 10:29:34,371: reraise(exc_type, exc_value, tb)
2017-11-30 10:29:34,371: File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 33, in reraise
2017-11-30 10:29:34,371: raise value
2017-11-30 10:29:34,371: File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1639, in full_dispatch_request
2017-11-30 10:29:34,371: rv = self.dispatch_request()
2017-11-30 10:29:34,371: File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1625, in dispatch_request
2017-11-30 10:29:34,371: return self.view_functions[rule.endpoint](**req.view_args)
2017-11-30 10:29:34,371: File "/home/giftcardsindia/amazonfeed/flask_app.py", line 13, in hello_world
2017-11-30 10:29:34,372: response = amazon.ItemSearch(Keywords="Kindle 3G", SearchIndex="All")
2017-11-30 10:29:34,372: File "/usr/local/lib/python3.5/dist-packages/bottlenose/api.py", line 251, in __call__
2017-11-30 10:29:34,372: {'api_url': api_url, 'cache_url': cache_url})
2017-11-30 10:29:34,372: File "/usr/local/lib/python3.5/dist-packages/bottlenose/api.py", line 212, in _call_api
2017-11-30 10:29:34,372: return urllib2.urlopen(api_request, timeout=self.Timeout)
2017-11-30 10:29:34,372: File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
2017-11-30 10:29:34,372: return opener.open(url, data, timeout)
2017-11-30 10:29:34,372: File "/usr/lib/python3.5/urllib/request.py", line 472, in open
2017-11-30 10:29:34,372: response = meth(req, response)
2017-11-30 10:29:34,372: File "/usr/lib/python3.5/urllib/request.py", line 582, in http_response
2017-11-30 10:29:34,373: 'http', request, response, code, msg, hdrs)
2017-11-30 10:29:34,373: File "/usr/lib/python3.5/urllib/request.py", line 510, in error
2017-11-30 10:29:34,373: return self._call_chain(*args)
2017-11-30 10:29:34,373: File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
2017-11-30 10:29:34,373: result = func(*args)
2017-11-30 10:29:34,373: File "/usr/lib/python3.5/urllib/request.py", line 590, in http_error_default
2017-11-30 10:29:34,373: raise HTTPError(req.full_url, code, msg, hdrs, fp)
2017-11-30 10:29:34,373: urllib.error.HTTPError: HTTP Error 403: Forbidden
2017-11-30 10:29:34,369: Exception on / [GET]#012Traceback (most recent call last):#012 File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1988, in wsgi_app#012 response = self.full_dispatch_request()#012 File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1641, in full_dispatch_request#012 rv = self.handle_user_exception(e)#012 File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1544, in handle_user_exception#012 reraise(exc_type, exc_value, tb)#012 File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 33, in reraise#012 raise value#012 File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1639, in full_dispatch_request#012 rv = self.dispatch_request()#012 File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1625, in dispatch_request#012 return self.view_functions[rule.endpoint](**req.view_args)#012 File "/home/giftcardsindia/amazonfeed/flask_app.py", line 13, in hello_world#012 response = amazon.ItemSearch(Keywords="Kindle 3G", SearchIndex="All")#012 File "/usr/local/lib/python3.5/dist-packages/bottlenose/api.py", line 251, in __call__#012 {'api_url': api_url, 'cache_url': cache_url})#012 File "/usr/local/lib/python3.5/dist-packages/bottlenose/api.py", line 212, in _call_api#012 return urllib2.urlopen(api_request, timeout=self.Timeout)#012 File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen#012 return opener.open(url, data, timeout)#012 File "/usr/lib/python3.5/urllib/request.py", line 472, in open#012 response = meth(req, response)#012 File "/usr/lib/python3.5/urllib/request.py", line 582, in http_response#012 'http', request, response, code, msg, hdrs)#012 File "/usr/lib/python3.5/urllib/request.py", line 510, in error#012 return self._call_chain(*args)#012 File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain#012 result = func(*args)#012 File "/usr/lib/python3.5/urllib/request.py", line 590, in http_error_default#012 raise HTTPError(req.full_url, code, msg, hdrs, fp)#012urllib.error.HTTPError: HTTP Error 403: Forbidden