我正在尝试使用 Python 连接器和 SSO 连接到 Snowflake。我希望连接器打开浏览器来验证用户身份,但这不起作用:
h:\Code\bin>python conn.py
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...
浏览器窗口永远不会弹出,而是立即得到以下内容
Traceback (most recent call last):
File "conn.py", line 9, in <module>
authenticator='externalbrowser'
File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\snowflake\connector\__init__.py", line 53, in Connect
return SnowflakeConnection(**kwargs)
File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\snowflake\connector\connection.py", line 187, in __init__
self.connect(**kwargs)
File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\snowflake\connector\connection.py", line 484, in connect
self.__open_connection()
File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\snowflake\connector\connection.py", line 699, in __open_connection
self.__authenticate(auth_instance)
File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\snowflake\connector\connection.py", line 922, in __authenticate
password=self._password,
File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\snowflake\connector\auth_webbrowser.py", line 104, in authenticate
authenticator, service_name, account, callback_port, user)
File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\snowflake\connector\auth_webbrowser.py", line 305, in _get_sso_url
socket_timeout=self._rest._connection.login_timeout)
File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\snowflake\connector\network.py", line 530, in _post_request
_include_retry_params=_include_retry_params)
File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\snowflake\connector\network.py", line 609, in fetch
**kwargs)
File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\snowflake\connector\network.py", line 711, in _request_exec_wrapper
raise e
File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\snowflake\connector\network.py", line 653, in _request_exec_wrapper
method, full_url, headers, data, conn)
File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\snowflake\connector\network.py", line 758, in _handle_unknown_error
u'errno': ER_FAILED_TO_REQUEST,
File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\snowflake\connector\errors.py", line 100, in errorhandler_wrapper
connection.errorhandler(connection, cursor, errorclass, errorvalue)
File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\snowflake\connector\errors.py", line 73, in default_errorhandler
done_format_msg=errorvalue.get(u'done_format_msg'))
snowflake.connector.errors.OperationalError: 250003: Failed to get the response. Hanging? method: post, url: https://<ACCOUNT>:443/session/authenticator-request?request_guid=<guid>
剧本:
import snowflake.connector
con = snowflake.connector.connect(
user='XXXX',
password='XXXX',
account='My account>',
warehouse='DEMO_WH',
database='DEV',
schema='TPCH_SF1000',
authenticator='externalbrowser'
)
>python --version
Python 3.6.5
>>pip3 list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
agate (1.6.1)
asn1crypto (1.3.0)
attrs (19.3.0)
azure-common (1.1.25)
azure-core (1.7.0)
azure-storage-blob (2.1.0)
azure-storage-common (2.1.0)
Babel (2.8.0)
boto3 (1.11.17)
botocore (1.14.17)
cachetools (4.1.1)
certifi (2020.6.20)
cffi (1.13.2)
chardet (3.0.4)
colorama (0.4.3)
cryptography (2.9.2)
cx-Oracle (8.0.0)
dataclasses (0.6)
dbt (0.17.0)
dbt-bigquery (0.17.0)
dbt-core (0.17.0)
dbt-postgres (0.17.0)
dbt-redshift (0.17.0)
dbt-snowflake (0.17.0)
decorator (4.4.2)
docutils (0.15.2)
google-api-core (1.16.0)
google-auth (1.19.0)
google-cloud-bigquery (1.24.0)
google-cloud-core (1.3.0)
google-resumable-media (0.5.1)
googleapis-common-protos (1.6.0)
hologram (0.0.7)
idna (2.8)
ijson (2.6.1)
importlib-metadata (1.7.0)
isodate (0.6.0)
Jinja2 (2.11.2)
jmespath (0.10.0)
json-rpc (1.13.0)
jsonschema (3.1.1)
leather (0.3.3)
Logbook (1.5.3)
MarkupSafe (1.1.1)
minimal-snowplow-tracker (0.0.2)
msrest (0.6.17)
networkx (2.4)
oauthlib (3.1.0)
oscrypto (1.2.0)
parsedatetime (2.6)
pip (9.0.3)
protobuf (3.11.3)
psycopg2-binary (2.8.5)
pyasn1 (0.4.8)
pyasn1-modules (0.2.8)
pycparser (2.20)
pycryptodomex (3.9.8)
PyJWT (1.7.1)
pyOpenSSL (19.1.0)
pyrsistent (0.16.0)
python-dateutil (2.8.1)
python-slugify (4.0.1)
pytimeparse (1.1.8)
pytz (2020.1)
PyYAML (5.3.1)
requests (2.22.0)
requests-oauthlib (1.3.0)
rsa (4.6)
s3transfer (0.3.3)
setuptools (39.0.1)
six (1.15.0)
snowflake-connector-python (2.2.1)
sqlparse (0.3.1)
text-unidecode (1.3)
typing-extensions (3.7.4.2)
urllib3 (1.25.9)
Werkzeug (0.16.1)
zipp (3.1.0)
我可以确认我可以使用 DBD::ODBC 与 Perl 连接,因此外部浏览器验证器原则上可以工作,但我只是不确定为什么它不适用于 Python