snowflakedb / snowflake-connector-python

Snowflake Connector for Python
https://pypi.python.org/pypi/snowflake-connector-python/
Apache License 2.0
585 stars 468 forks source link

SNOW-574273: Initiating login request with your identity provider. A browser window should have opened for you to complete the login. #1090

Closed popcsev closed 1 year ago

popcsev commented 2 years ago

Please answer these questions before submitting your issue. Thanks!

  1. What version of Python are you using?

Using Python 3.9.7 and I am running the script on Jupyterlab 2.3.1

  1. What operating system and processor architecture are you using?

macOS-12.0.1-arm64-arm-64bit

  1. What are the component versions in the environment (pip freeze)?

anyio @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/croot-t_zs64wy/anyio_1644482593257/work/dist appnope @ file:///Users/ktietz/demo/mc3/conda-bld/appnope_1629146036738/work argon2-cffi @ file:///opt/conda/conda-bld/argon2-cffi_1645000214183/work argon2-cffi-bindings @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/croot-wbf5edig/argon2-cffi-bindings_1644845754377/work asn1crypto==1.5.1 attrs @ file:///opt/conda/conda-bld/attrs_1642510447205/work Babel @ file:///tmp/build/80754af9/babel_1620871417480/work backcall @ file:///home/ktietz/src/ci/backcall_1611930011877/work bleach @ file:///opt/conda/conda-bld/bleach_1641577558959/work Bottleneck @ file:///Users/ktietz/demo/mc3/conda-bld/bottleneck_1629791503532/work brotlipy==0.7.0 cachetools==5.0.0 certifi==2021.10.8 cffi @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/croot-jgj0vmyy/cffi_1642701117808/work chardet==4.0.0 charset-normalizer @ file:///tmp/build/80754af9/charset-normalizer_1630003229654/work cmdstanpy==0.9.68 convertdate==2.4.0 cryptography @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/croot-cn99yw1m/cryptography_1639499039549/work cycler @ file:///tmp/build/80754af9/cycler_1637851556182/work Cython==0.29.28 db-dtypes==0.3.1 debugpy @ file:///Users/builder/miniconda3/envs/prefect/conda-bld/debugpy_1637092214173/work decorator @ file:///opt/conda/conda-bld/decorator_1643638310831/work defusedxml @ file:///tmp/build/80754af9/defusedxml_1615228127516/work entrypoints==0.3 ephem==4.1.3 et-xmlfile==1.1.0 fonttools==4.25.0 gapandas==1.0 google-api-core==2.6.0 google-api-python-client==2.39.0 google-auth==2.6.0 google-auth-httplib2==0.1.0 google-auth-oauthlib==0.5.0 google-cloud-bigquery==2.34.1 google-cloud-bigquery-storage==2.12.0 google-cloud-core==2.2.2 google-crc32c==1.3.0 google-resumable-media==2.3.1 googleapis-common-protos==1.55.0 grpcio==1.44.0 grpcio-status==1.44.0 gspread==5.2.0 gspread-dataframe==3.2.2 hijri-converter==2.2.3 holidays==0.13 htmlmin==0.1.12 httplib2==0.20.4 idna @ file:///tmp/build/80754af9/idna_1637925883363/work ImageHash==4.2.1 importlib-metadata @ file:///Users/builder/miniconda3/envs/prefect/conda-bld/importlib-metadata_1638777154045/work ipykernel @ file:///Users/builder/miniconda3/envs/prefect/conda-bld/ipykernel_1637093280282/work/dist/ipykernel-6.4.1-py3-none-any.whl ipython @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/croot-i0k1c2sa/ipython_1643819080541/work ipython-genutils @ file:///tmp/build/80754af9/ipython_genutils_1606773439826/work ipywidgets==7.7.0 jedi @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/croot-f1t6hma6/jedi_1644315882177/work Jinja2 @ file:///tmp/build/80754af9/jinja2_1635780242639/work joblib==1.0.1 joypy==0.2.6 json5 @ file:///tmp/build/80754af9/json5_1624432770122/work jsonschema @ file:///Users/ktietz/demo/mc3/conda-bld/jsonschema_1630511932244/work jupyter-client @ file:///opt/conda/conda-bld/jupyter_client_1643638337975/work jupyter-core @ file:///Users/builder/miniconda3/envs/prefect/conda-bld/jupyter_core_1636622821915/work jupyter-server @ file:///opt/conda/conda-bld/jupyter_server_1644494914632/work jupyterlab==2.3.1 jupyterlab-pygments @ file:///tmp/build/80754af9/jupyterlab_pygments_1601490720602/work jupyterlab-server @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_server_1593951277307/work jupyterlab-widgets==1.1.0 kiwisolver @ file:///Users/builder/miniconda3/envs/prefect/conda-bld/kiwisolver_1638569888412/work korean-lunar-calendar==0.2.1 LunarCalendar==0.0.9 MarkupSafe @ file:///Users/ktietz/demo/mc3/conda-bld/markupsafe_1629137411893/work matplotlib @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/croot-wwa3bwxq/matplotlib-suite_1645462191063/work matplotlib-inline @ file:///tmp/build/80754af9/matplotlib-inline_1628242447089/work missingno==0.5.1 mistune @ file:///Users/ktietz/demo/mc3/conda-bld/mistune_1629356075445/work multimethod==1.7 munkres==1.1.4 nbclassic @ file:///opt/conda/conda-bld/nbclassic_1644943264176/work nbclient @ file:///tmp/build/80754af9/nbclient_1645431659072/work nbconvert @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/croot-dl85zlms/nbconvert_1641309203294/work nbformat @ file:///tmp/build/80754af9/nbformat_1617383369282/work nest-asyncio @ file:///tmp/build/80754af9/nest-asyncio_1613680548246/work networkx==2.7 notebook @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/croot-837tqlch/notebook_1645007402196/work numexpr @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/croot-ny1mxojk/numexpr_1640704752206/work numpy @ file:///Users/ktietz/ci_310/numpy_and_numpy_base_1644255410823/work oauth2client==4.1.3 oauthlib==3.2.0 openpyxl @ file:///tmp/build/80754af9/openpyxl_1632777717936/work oscrypto==1.3.0 packaging @ file:///tmp/build/80754af9/packaging_1637314298585/work pandas==1.4.1 pandas-gbq==0.17.2 pandas-profiling==3.1.0 pandocfilters @ file:///opt/conda/conda-bld/pandocfilters_1643405455980/work parso @ file:///opt/conda/conda-bld/parso_1641458642106/work pexpect @ file:///tmp/build/80754af9/pexpect_1605563209008/work phik==0.12.0 pickleshare @ file:///tmp/build/80754af9/pickleshare_1606932040724/work Pillow==9.0.1 prometheus-client @ file:///opt/conda/conda-bld/prometheus_client_1643788673601/work prompt-toolkit @ file:///tmp/build/80754af9/prompt-toolkit_1633440160888/work prophet==1.0.1 proto-plus==1.20.3 protobuf==3.19.4 ptyprocess @ file:///tmp/build/80754af9/ptyprocess_1609355006118/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl pyarrow==6.0.1 pyasn1==0.4.8 pyasn1-modules==0.2.8 pycparser @ file:///tmp/build/80754af9/pycparser_1636541352034/work pycryptodomex==3.14.1 pydantic==1.9.0 pydata-google-auth==1.3.0 Pygments @ file:///opt/conda/conda-bld/pygments_1644249106324/work PyJWT==2.3.0 PyMeeus==0.5.11 pyOpenSSL==21.0.0 pyparsing @ file:///tmp/build/80754af9/pyparsing_1635766073266/work pyrsistent @ file:///Users/ktietz/demo/mc3/conda-bld/pyrsistent_1628941062930/work PySocks @ file:///Users/ktietz/Code/oss/ci_pkgs/pysocks_1626781349491/work pystan==2.19.1.1 python-dateutil @ file:///tmp/build/80754af9/python-dateutil_1626374649649/work pytz==2021.3 PyWavelets==1.2.0 PyYAML==6.0 pyzmq @ file:///Users/builder/miniconda3/envs/prefect/conda-bld/pyzmq_1638447141825/work requests @ file:///opt/conda/conda-bld/requests_1641824580448/work requests-oauthlib==1.3.1 rsa==4.8 scipy @ file:///Users/ktietz/ci_310/scipy_1644255974431/work seaborn @ file:///tmp/build/80754af9/seaborn_1629307859561/work Send2Trash @ file:///tmp/build/80754af9/send2trash_1632406701022/work setuptools-git==1.2 six @ file:///tmp/build/80754af9/six_1644875935023/work sniffio @ file:///Users/ktietz/demo/mc3/conda-bld/sniffio_1629145892482/work snowflake-connector-python==2.7.6 snowflake-sqlalchemy==1.3.3 SQLAlchemy==1.4.35 tangled-up-in-unicode==0.1.0 terminado @ file:///private/var/folders/nz/j6p8yfhx1mv_0grj5xl4650h0000gp/T/croot-n1puqh63/terminado_1644395131327/work testpath @ file:///tmp/build/80754af9/testpath_1624638946665/work tornado @ file:///Users/ktietz/demo/mc3/conda-bld/tornado_1628698929452/work tqdm==4.63.0 traitlets @ file:///tmp/build/80754af9/traitlets_1636710298902/work typing-extensions @ file:///tmp/build/80754af9/typing_extensions_1631814937681/work ujson==5.1.0 uritemplate==4.1.1 urllib3 @ file:///opt/conda/conda-bld/urllib3_1643638302206/work visions==0.7.4 wcwidth @ file:///Users/ktietz/demo/mc3/conda-bld/wcwidth_1629357192024/work webencodings==0.5.1 websocket-client @ file:///Users/ktietz/demo/mc3/conda-bld/websocket-client_1629357070578/work widgetsnbextension==3.6.0 zipp @ file:///opt/conda/conda-bld/zipp_1641824620731/work

  1. What did you do?

https://community.snowflake.com/s/article/External-browser-SSO-from-connector-fails-on-redirect-back-to-localhost

I tried to remove the localhost in Chrome from my browser's HSTS settings.

  1. What did you expect to see?

I expected the my default Chrome browser to open for authentication. Instead, the got the error below. I replaced the username and the account paramers the other paramers are the real inputs

  1. Can you set logging to DEBUG and collect the logs?

    
    import snowflake.connector as sf

con = sf.connect( user='username@domain.com', password='', account='account', authenticator='externalbrowser', warehouse = 'GBI_DI_WH', database = 'GBI_DL_DB', schema = 'DW2_DEV' )

cs = con.cursor()

Initiating login request with your identity provider. A browser window should have opened for you to complete the login. If you can't see it, check existing browser windows, or your OS settings. Press CTRL+C to abort and try again...

MemoryError Traceback (most recent call last) /var/folders/5f/075258sn2wz0s6vh9xm0hm5m0000gn/T/ipykernel_14282/3352092842.py in ----> 1 con = sf.connect( 2 user='username@domain.com', 3 password='', 4 account='account', 5 authenticator='externalbrowser',

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/init.py in Connect(kwargs) 49 50 def Connect(kwargs) -> SnowflakeConnection: ---> 51 return SnowflakeConnection(**kwargs) 52 53

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/connection.py in init(self, kwargs) 271 self.converter = None 272 self.__set_error_attributes() --> 273 self.connect(kwargs) 274 self._telemetry = TelemetryClient(self._rest) 275 # Some configuration files need to be updated here to make them testable

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/connection.py in connect(self, **kwargs) 492 TelemetryService.get_instance().update_context(kwargs) 493 --> 494 self.__open_connection() 495 496 def close(self, retry=True):

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/connection.py in __open_connection(self) 731 auth = Auth(self.rest) 732 auth.read_temporary_credentials(self.host, self.user, self._session_parameters) --> 733 self._authenticate(auth_instance) 734 735 self._password = None # ensure password won't persist

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/connection.py in _authenticate(self, auth_instance) 992 # make some changes if needed before real authenticate 993 try: --> 994 self.authenticate(self.__preprocess_auth_instance(auth_instance)) 995 except ReauthenticationRequest as ex: 996 # cached id_token expiration error, we have cleaned id_token and try to authenticate again

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/connection.py in __authenticate(self, auth_instance) 999 1000 def __authenticate(self, auth_instance): -> 1001 auth_instance.authenticate( 1002 authenticator=self._authenticator, 1003 service_name=self.service_name,

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/auth_webbrowser.py in authenticate(self, authenticator, service_name, account, user, password) 125 126 logger.debug("step 1: query GS to obtain SSO url") --> 127 sso_url = self._get_sso_url( 128 authenticator, service_name, account, callback_port, user 129 )

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/auth_webbrowser.py in _get_sso_url(self, authenticator, service_name, account, callback_port, user) 355 "account=%s, authenticator=%s, user=%s", account, authenticator, user 356 ) --> 357 ret = self._rest._post_request( 358 url, 359 headers,

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/network.py in _post_request(self, url, headers, body, token, timeout, _no_results, no_retry, socket_timeout, _include_retry_params) 701 pprint(ret) 702 --> 703 ret = self.fetch( 704 "post", 705 full_url,

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/network.py in fetch(self, method, full_url, headers, data, timeout, kwargs) 791 retry_ctx = RetryCtx(timeout, include_retry_params) 792 while True: --> 793 ret = self._request_exec_wrapper( 794 session, method, full_url, headers, data, retry_ctx, kwargs 795 )

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/network.py in _request_exec_wrapper(self, session, method, full_url, headers, data, retry_ctx, no_retry, token, **kwargs) 913 except Exception as e: 914 if not no_retry: --> 915 raise e 916 logger.debug("Ignored error", exc_info=True) 917 return {}

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/network.py in _request_exec_wrapper(self, session, method, full_url, headers, data, retry_ctx, no_retry, token, **kwargs) 834 full_url = SnowflakeRestful.add_request_guid(full_url) 835 try: --> 836 return_object = self._request_exec( 837 session=session, 838 method=method,

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/network.py in _request_exec(self, session, method, full_url, headers, data, token, catch_okta_unauthorized_error, is_raw_text, is_raw_binary, binary_data_handler, socket_timeout) 1087 stack_trace=traceback.format_exc(), 1088 ) -> 1089 raise err 1090 1091 def make_requests_session(self):

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/network.py in _request_exec(self, session, method, full_url, headers, data, token, catch_okta_unauthorized_error, is_raw_text, is_raw_binary, binary_data_handler, socket_timeout) 989 # the response within the time. If not, ConnectReadTimeout or 990 # ReadTimeout is raised. --> 991 raw_ret = session.request( 992 method=method, 993 url=full_url,

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/vendored/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json) 540 } 541 send_kwargs.update(settings) --> 542 resp = self.send(prep, **send_kwargs) 543 544 return resp

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/vendored/requests/sessions.py in send(self, request, kwargs) 653 654 # Send the request --> 655 r = adapter.send(request, kwargs) 656 657 # Total elapsed time of the request (approximately)

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/vendored/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies) 437 try: 438 if not chunked: --> 439 resp = conn.urlopen( 440 method=request.method, 441 url=url,

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw) 697 698 # Make the request on the httplib connection object. --> 699 httplib_response = self._make_request( 700 conn, 701 method,

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw) 380 # Trigger any extra validation we need to do. 381 try: --> 382 self._validate_conn(conn) 383 except (SocketTimeout, BaseSSLError) as e: 384 # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py in _validate_conn(self, conn) 1008 # Force connect early to allow us to validate the connection. 1009 if not getattr(conn, "sock", None): # AppEngine might not have .sock -> 1010 conn.connect() 1011 1012 if not conn.is_verified:

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/vendored/urllib3/connection.py in connect(self) 390 if self.ssl_context is None: 391 default_ssl_context = True --> 392 self.ssl_context = create_urllib3_context( 393 ssl_version=resolve_ssl_version(self.ssl_version), 394 cert_reqs=resolve_cert_reqs(self.cert_reqs),

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/vendored/urllib3/util/ssl_.py in create_urllib3_context(ssl_version, cert_reqs, options, ciphers) 337 # or not so we don't know the initial state of the freshly created SSLContext. 338 if cert_reqs == ssl.CERT_REQUIRED: --> 339 context.verify_mode = cert_reqs 340 disable_check_hostname() 341 else:

~/miniconda3/envs/bq/lib/python3.9/site-packages/snowflake/connector/vendored/urllib3/contrib/pyopenssl.py in verify_mode(self, value) 442 @verify_mode.setter 443 def verify_mode(self, value): --> 444 self._ctx.set_verify(_stdlib_to_openssl_verify[value], _verify_callback) 445 446 def set_default_verify_paths(self):

~/miniconda3/envs/bq/lib/python3.9/site-packages/OpenSSL/SSL.py in set_verify(self, mode, callback) 1082 raise TypeError("callback must be callable") 1083 -> 1084 self._verify_helper = _VerifyHelper(callback) 1085 self._verify_callback = self._verify_helper.callback 1086 _lib.SSL_CTX_set_verify(self._context, mode, self._verify_callback)

~/miniconda3/envs/bq/lib/python3.9/site-packages/OpenSSL/SSL.py in init(self, callback) 355 return 0 356 --> 357 self.callback = _ffi.callback( 358 "int ()(int, X509_STORE_CTX )", wrapper 359 )

MemoryError: Cannot allocate write+execute memory for ffi.callback(). You might be running on a system that prevents this. For more information, see https://cffi.readthedocs.io/en/latest/using.html#callbacks



<!--
If you need urgent assistance reach out to support for escalated issue processing https://community.snowflake.com/s/article/How-To-Submit-a-Support-Case-in-Snowflake-Lodge
-->
github-actions[bot] commented 1 year ago

To clean up and re-prioritize bugs and feature requests we are closing all issues older than 6 months as of March 1, 2023. If there are any issues or feature requests that you would like us to address, please re-create them. For urgent issues, opening a support case with this link Snowflake Community is the fastest way to get a response