Forums

OSError: Tunnel connection failed: 403 Forbidden

Hi, When I upload my working code from my Windows computer to Python Anywhere, I" getting this error: OSError: Tunnel connection failed: 403 Forbidden

I'm using the Adobe extract API

Thanks for your help

If you can help me please: My error is: ERROR:root:Exception encountered while executing operation
Traceback (most recent call last):
File "/home/extractorai/.local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 700, in urlopen
self._prepare_proxy(conn)
File "/home/extractorai/.local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 994, in _prepare_proxy
conn.connect()
File "/home/extractorai/.local/lib/python3.9/site-packages/urllib3/connection.py", line 371, in connect
self._tunnel()
File "/usr/local/lib/python3.9/http/client.py", line 903, in _tunnel
raise OSError(f"Tunnel connection failed: {code} {message.strip()}")
OSError: Tunnel connection failed: 403 Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/home/extractorai/.local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "/home/extractorai/.local/lib/python3.9/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ims-na1.adobelogin.com', port=443): Max retries exceeded with url: /ims/exchange/jwt/ (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunn el connection failed: 403 Forbidden')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/extractorai/.local/lib/python3.9/site-packages/adobe/pdfservices/operation/internal/http/http_client.py", line 65, in _execute_request
response = requests.post(url=http_request.url,
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 119, in post
return request('post', url, data=data, json=json, kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url,
kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, send_kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request,
kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 510, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='ims-na1.adobelogin.com', port=443): Max retries exceeded with url: /ims/exchange/jwt/ (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/extractorai/.local/lib/python3.9/site-packages/adobe/pdfservices/operation/internal/auth/jwt_authenticator.py", line 62, in refresh_token
response = http_client.process_request(http_request=http_request, success_status_codes=[HTTPStatus.OK],
File "/home/extractorai/.local/lib/python3.9/site-packages/adobe/pdfservices/operation/internal/http/http_client.py", line 41, in process_request
response = _execute_request(http_request)
File "/home/extractorai/.local/lib/python3.9/site-packages/adobe/pdfservices/operation/internal/http/http_client.py", line 81, in _execute_request
raise SdkException("Request could not be completed. Possible cause attached!", sys.exc_info())
adobe.pdfservices.operation.exception.exceptions.SdkException: description =Request could not be completed. Possible cause attached!, requestTrackingId=(<class 'requests.exceptions.ProxyError'>, ProxyError(Max RetryError("HTTPSConnectionPool(host='ims-na1.adobelogin.com', port=443): Max retries exceeded with url: /ims/exchange/jwt/ (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden')))")), <traceback object at 0x7f60156e3c80>)

During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/extractorai/test/./src/extract_txt_from_pdf.py", line 48, in <module> result: FileRef = extract_pdf_operation.execute(execution_context) File "/home/extractorai/.local/lib/python3.9/site-packages/adobe/pdfservices/operation/pdfops/extract_pdf_operation.py", line 131, in execute location = ExtractPDFAPI.extract_pdf(execution_context, self._source_file_ref, self._extract_pdf_options) File "/home/extractorai/.local/lib/python3.9/site-packages/adobe/pdfservices/operation/internal/service/extract_pdf_api.py", line 42, in extract_pdf location = CPFApi.cpf_create_ops_api(context, cpf_content_analyzer_req, [file_ref], File "/home/extractorai/.local/lib/python3.9/site-packages/adobe/pdfservices/operation/internal/api/cpf_api.py", line 63, in cpf_create_ops_api response = http_client.process_request(http_request=http_request, File "/home/extractorai/.local/lib/python3.9/site-packages/adobe/pdfservices/operation/internal/http/http_client.py", line 35, in process_request access_token = http_request.authenticator.session_token().access_token File "/home/extractorai/.local/lib/python3.9/site-packages/adobe/pdfservices/operation/internal/auth/jwt_authenticator.py", line 45, in session_token return self.refresh_token() File "/home/extractorai/.local/lib/python3.9/site-packages/adobe/pdfservices/operation/internal/auth/jwt_authenticator.py", line 67, in refresh_token raise SdkException("Exception in fetching access token", sys.exc_info()) adobe.pdfservices.operation.exception.exceptions.SdkException: description =Exception in fetching access token, requestTrackingId=(<class 'adobe.pdfservices.operation.exception.exceptions.SdkException'>, SdkEx ception('Request could not be completed. Possible cause attached!', (<class 'requests.exceptions.ProxyError'>, ProxyError(MaxRetryError("HTTPSConnectionPool(host='ims-na1.adobelogin.com', port=443): Max retrie s exceeded with url: /ims/exchange/jwt/ (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden')))")), <traceback object at 0x7f60156e3c80>)), <traceback object at 0 x7f60156f8e00>)

See https://help.pythonanywhere.com/pages/RequestingWhitelistAdditions/

hello Glenn,

please can you whitelist the sites (www.paygold.ng and www.paystack.com) for api access. their official api documentation can be found at www.paygold.ng/api and https://paystack.com/docs respectively.

thanks

@piebeeper1 api.paystack.co and paygold.ng have been added to the whitelist.