【发布时间】:2020-04-08 21:01:55
【问题描述】:
根据这个页面。
仅当客户端在 Windows 环境下时,才支持基于 AAD 令牌的身份验证来访问 Azure SQL DB。
MacOS 和 Linux 能否支持基于 AAD 令牌的身份验证来访问 Azure SQL DB?
https://github.com/mkleehammer/pyodbc/issues/228
token = context.acquire_token_with_client_credentials(
database_url,
azure_client_id,
azure_client_secret
)
print(token)
tokenb = bytes(token["accessToken"], "UTF-8")
exptoken = b''
for i in tokenb:
exptoken += bytes({i})
exptoken += bytes(1)
tokenstruct = struct.pack("=i", len(exptoken)) + exptoken
tokenstruct
SQL_COPT_SS_ACCESS_TOKEN = 1256
CONNSTRING = "DRIVER={};SERVER={};DATABASE={}".format("ODBC Driver 17 for SQL Server", prod_server, prod_db)
db_connector = pyodbc.connect(CONNSTRING, attrs_before={SQL_COPT_SS_ACCESS_TOKEN: tokenstruct})
这是我在MacOS下运行的代码,是python。
我不断收到这个问题
pyodbc.InterfaceError: ('28000', "[28000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user ''. (18456) (SQLDriverConnect)")
有人有想法吗?
【问题讨论】:
标签: azure azure-active-directory azure-sql-database