-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ISSUE] 'dict' object is not callable when m2m authentication #776
Comments
Getting the same error. Repro + stacktrace/debug logs below. import logging
import os
import sys
from databricks import sql
from databricks.sdk.core import Config, oauth_service_principal
logging.basicConfig(
stream=sys.stderr,
level=logging.INFO,
format="%(asctime)s [%(name)s][%(levelname)s] %(message)s",
)
logging.getLogger("databricks.sdk").setLevel(logging.DEBUG)
logging.getLogger("databricks.sql").setLevel(logging.DEBUG)
host = os.getenv("DATABRICKS_HOST")
http_path = os.getenv("DATABRICKS_HTTP_PATH")
client_id = os.getenv("DATABRICKS_OAUTH_CLIENT_ID")
client_secret = os.getenv("DATABRICKS_OAUTH_CLIENT_SECRET")
conn = sql.connect(
server_hostname=host,
http_path=http_path,
credentials_provider=oauth_service_principal(
Config(
host=f"https://{host}",
client_id=client_id,
client_secret=client_secret,
)
),
)
|
This may be related to the discussion here: databricks/databricks-sql-python#423 Fixed using @kravets-levko's example below from databricks.sdk.core import Config, oauth_service_principal
from databricks import sql
import os
server_hostname = os.getenv("DATABRICKS_SERVER_HOSTNAME")
def credential_provider():
config = Config(
host = f"https://{server_hostname}",
client_id = os.getenv("DATABRICKS_CLIENT_ID"),
client_secret = os.getenv("DATABRICKS_CLIENT_SECRET")
)
def get_headers():
return oauth_service_principal(config)
return get_headers
with sql.connect(server_hostname = server_hostname,
http_path = os.getenv("DATABRICKS_HTTP_PATH"),
credentials_provider = credential_provider) as connection: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
I´m trying to connect m2m to databricks following the instructions in Databricks but when running the code I am getting the following error:
From what I could see the class OAuthCredentialsProvider extends from CredentialsProvider, however the class CredentialsProvider in the databricks-sql-connector dont match the output, one directly return dict while the other return Callable[[], Dict[str, str]].
Is there something I am missing? Shouldnt these two classes be compatible?
Reproduction
Available in Databricks
Expected behavior
Everything work and return the result query.
Is it a regression?
Did this work in a previous version of the SDK? If so, which versions did you try?
Didn´t test
Other Information
The text was updated successfully, but these errors were encountered: